mardi 4 février 2020

How do i get result by comparing Date column and Time column when Date and Time column are separate columns in Laravel

I want to fetch events based on their end_date and end_time from events table. So i need to fetch those events only which are in the future. So if current date and time is greater than end_date and end_time then then it should not fetch those records because the the date and time has passed.

I have done so far :

$today = Carbon::now();

return $query->where('end_date', '>=', today()->format('Y-m-d'))
            ->where('end_time', '>=', $today->toTimeString());

But this code will not work as expected.

How can i write a query where i will be able to check first if date is today then only check time.

Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire