I have used below query to get result with some codition in my controller
$events = Event::whereHas('topic', function ($q) {
$q->where('delete_status', 0);
})
->where('status', 1)
->where('delete_status', 0);
And in my view file i have used this variable thrice to check with Date like below
$events->where('type', '!=', 2)->whereDate('start_date', '>=', \Carbon\Carbon::now())->get()
And
$events->where('type', 2)->whereDate('start_date', '>=', \Carbon\Carbon::now())->get()
And
$events->whereDate('start_date', '<', \Carbon\Carbon::now())->get()
Because i want to get the result based on past date or present date. If i use get in controller query i got error of whereDate() does not exists So i have used get() method in view file.
I cannot get record from second and third query but I can only get record from 1st query in view file.
Any solution?