php - Cannot compare Carbon instances in Laravel 5? -


i working fullcalendar plugin , trying fetch events in database after , before date. full calendar paginates events adding paramaters called 'start' , 'end'. able parse these in carbon instances so:

carbon::parse($data['start']); carbon::parse($data['end']); 

now working fine:

$events = $this->event->where('user_id', auth()->user()->id)                         ->get(); 

but not:

$events = $this->event->where('user_id', auth()->user()->id)                         ->where('start', '>=', carbon::parse($data['start']))                         ->where('end', '<=', carbon::parse($data['end']))                         ->get(); 

why not getting events published between these 2 dates second approach. when run first approach, works fine , fetches events , publishes them on current page unfortunately fetching whole lot of events don't need fetching.

after listening db queries, event query like:

select * events user_id = ? , start >= ? , end <= ?

this small mistake on end not setting end date event in db , hence query events authenticated users working correctly.

in fact query >= start have worked alone the <= end creating issue since end null , hence eloquent not returning models.


Comments

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -