lundi 10 juillet 2017

Laravel 5 how relation two fields, date and time in a query with where

I have two fields in a table: date and time, and I want to show all items with this conditions:

 $now = date('Y-m-d');
 $time = date('H:i:s');

 $news = News::where('date', '<=', $now)->where('time', '<=', $time)->where('active', '1')->orderBy('date', 'desc')->orderBy('time', 'desc')->get();

And I want to condition the time to the date. I mean that if the date is less than today then the time does not have to affect.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2uHiWbf
via IFTTT

Aucun commentaire:

Enregistrer un commentaire