In your example I don't see why it wouldn't retrieve all of the records
Sep 3, 2017
7
Level 2
How to group by desc order with laravel?
Hi, I need to group some data, unfortunately though, I always get the lowest id, while I would like the highest one.
ID | id_topic
1 | 1
2 | 1
3 | 2
In this example, laravel prints to me:
ID | id_topic
3 | 2
1 | 1
while I would like:
ID | id_topic
3 | 2
2 | 1
My query is:
$topic = Forum_topic::with('lastpost','autore')->where('id_sezione', $sezione->id)->groupby('id_topic')->orderby('ID', 'DESC')->get();
Unfortunately, however, it seems that "orderby" does not work...
Please or to participate in this conversation.