@@ -205,8 +205,8 @@ protected function getIsCheckedOutAttribute(): bool
205205 public function scopeBetween (Builder $ query , $ start , $ end ): Builder
206206 {
207207 // Make sure dates are Carbon objects.
208- $ start = Carbon:: parse (( is_numeric ($ start ) ? ' @ ' : '' ). $ start );
209- $ end = Carbon:: parse (( is_numeric ($ end ) ? ' @ ' : '' ). $ end );
208+ $ start = is_numeric ($ start ) ? Carbon:: createFromTimestamp ( $ start ) : Carbon:: parse ( $ start );
209+ $ end = is_numeric ($ end ) ? Carbon:: createFromTimestamp ( $ end ) : Carbon:: parse ( $ end );
210210
211211 // Add second and subtract second to allow booking to start or end at same time.
212212 $ startTime = $ start ->copy ()->addSecond ();
@@ -216,15 +216,17 @@ public function scopeBetween(Builder $query, $start, $end): Builder
216216 return $ query ->where (function ($ query ) use ($ startTime , $ endTime ) {
217217 $ query
218218 // Exactly the same time as given interval.
219- ->where ([
220- ['start_time ' , $ startTime ->copy ()->subSecond ()],
221- ['end_time ' , $ endTime ->copy ()->addSecond ()],
222- ])
219+ ->where (function ($ query ) use ($ startTime , $ endTime ) {
220+ $ query
221+ ->where ('start_time ' , '= ' , $ startTime ->copy ()->subSecond ())
222+ ->where ('end_time ' , '= ' , $ endTime ->copy ()->addSecond ());
223+ })
223224 // Start before and end after interval.
224- ->orWhere ([
225- ['start_time ' , '< ' , $ startTime ],
226- ['end_time ' , '> ' , $ endTime ],
227- ])
225+ ->orWhere (function ($ query ) use ($ startTime , $ endTime ) {
226+ $ query
227+ ->where ('start_time ' , '< ' , $ startTime )
228+ ->where ('end_time ' , '> ' , $ endTime );
229+ })
228230 // Start in interval.
229231 ->orWhereBetween ('start_time ' , [$ startTime , $ endTime ])
230232 // End in interval.
0 commit comments