I'm trying to make it so that the items pulled from the database are only from the current month, however when I do this using various methods it throws an error (which I can't debug due to a the issue mentioned here). In the code below if I just simply paginate the full results it works fine, but when I start to use query builder methods it gives an error, does anybody have any idea why this error is occurring?
public function index()
{
// $trades=Trade::paginate(10);
$currentMonth = date('m');
$trades = DB::table('trades')->whereMonth('date', $currentMonth)->paginate(10);
// dd($trades);
$pastwinners=Winner::paginate(10);
return view('raffle', compact('pastwinners'), compact('trades'));
}
As you can see above the $pastwinners variable and the first $trades variable provide the proper values, but when I'm trying to select only the ones from this month (using the 'date' field) it seems to break.