9 months ago

whereBetween does not exist

Posted 9 months ago by jonassiewertsen

Does anybody has a clue, why i'm getting this error?

It is working perfectly, exactly as i want it to on my dev server. Still, PHP Unit is squawking and giving me an error. It just doesn't makes sense ...

BadMethodCallException: Method Illuminate\Database\Eloquent\Collection::whereBetween does not exist.

My Controller looks like:

$bookings = auth()->user()->bookings()->get();

$thisWeek = $bookings->whereBetween('date', [
   now()->format('Y-m-d'), now()->endOfWeek()->format('Y-m-d')

My PHPUnit Test:

\\ $this->withoutExceptionhandling();

$booking = create('App\Booking', [
    'user_id' => $this->user->id,
     'date' => now()->format('Y-m-d'),


Does anybody has a clue?

Please sign in or create an account to participate in this conversation.