I have a mySql query that I need to convert using Eloquent(recommended) if possible.
Here is my query:
SELECT * FROM
( SELECT `uid`, `revision` FROM `tasks` ORDER BY `revision` DESC)
x GROUP by uid
Project model I have the following:
And now, How do I convert the sql query above using eloquent.
Any help is appreciated.
I found the solution. There is
DB::select in laravel which is essential in this case.
Here is the solution:
$sub = 'SELECT * FROM `tasks` ORDER BY `revision` DESC'; $results = DB::select( DB::raw('select * from (' . $sub . ') x GROUP by uid') );