Is it possible to combine those queries in one? What I need is to get 4 rows spaced by 6 hours from now.
$data1 = TransacoesRecentes::orderBy('created_at', 'desc')
->whereRaw('created_at <= NOW() - INTERVAL 24 HOUR')
->first();
$data2 = TransacoesRecentes::orderBy('created_at', 'desc')
->whereRaw('created_at <= NOW() - INTERVAL 18 HOUR')
->first();
$data3 = TransacoesRecentes::orderBy('created_at', 'desc')
->whereRaw('created_at <= NOW() - INTERVAL 12 HOUR')
->first();
$data4 = TransacoesRecentes::orderBy('created_at', 'desc')
->whereRaw('created_at <= NOW() - INTERVAL 6 HOUR')
->first();
Thanks.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Tm70wC
via IFTTT
Aucun commentaire:
Enregistrer un commentaire