I have a \"messages\" table with the following columns
CREATE TABLE `messages` ( `id` int(11) NOT NULL AUTO_INCREMENT, `fromId` int(11) NOT NULL, `toId
This work for me: (you can remove the order by createdAt in case createAt increase along with id)
DB::select(DB::raw('select * from (select * from messages group by fromId desc) m order by m.createdAt'));