Reputation: 804
I am trying to get only the current dates and the previous dates.Here is how i tried
$jobseekers = Calllog::orderBy('calllogs.created_at','DESC')
->get()->where('call_back_date', '<=', Carbon::today()->toDateString());
This show only the previous dates, i want to get both.If i remove "<", it shows only the current date.Help me out please.
Upvotes: 1
Views: 2650
Reputation: 133
use below eloquent query
$jobseekers = Calllog::whereDate('call_back_date','<=',Carbon::today)->get()
Upvotes: 1
Reputation: 775
$jobseekers = Calllog::orderBy('calllogs.created_at','DESC')->where('call_back_date', '<=', Carbon::now())->get();
Using now() instead of today(). Unlike today(), now() returns complete datetime at the moment.
Also notice that i moved where condition before get() to prevent fetching extra data from database.
Upvotes: 0
Reputation: 11340
Use tomorrow
and <
condition
$jobseekers = Calllog::orderBy('calllogs.created_at','DESC')
->get()->where('call_back_date', '<', Carbon::tomorrow()->toDateString());
Upvotes: 1