I am trying to get all of the rows with the latest dates
Assuming I have 5 records:
1 | 2019-09-13
2 | 2019-09-13
3 | 2019-09-14
4 | 2019-09-14
5 | 2019-09-14
When I use this eloquent query:
$items = Purchase::whereYear('created_at', '=', $year)
->whereMonth('created_at', '=', $month)
->where('created_at', Purchase::max('created_at'))
->get();
return $items;
It only returns only 1 record, and that is record #5.
I want to get the records 3, 4 , and 5. What's wrong with my query?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2QbV52j
via IFTTT
Aucun commentaire:
Enregistrer un commentaire