Answer the question
In order to leave comments, you need to log in
How to select the last entry in each group in Laravel?
There is a table with messages, the structure is simple: id, sender, recipient, chat_id
I need to display the last message in each of the chats
. Grouping by chat_id via ->groupBy('chat_id') gives the first entry.
->orderBy('id','desc') doesn't work here.
How to do?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question