If this
SELECT J.journal_name,V.id,V.journal_id FROM journals AS J
INNER JOIN (SELECT *
FROM volumes
WHERE id IN (
SELECT MAX(id)
FROM volumes
GROUP BY journal_id
)) AS V ON J.id = V.journal_id
Works use that.
You can still convert it to a query builder or eloquent query something like:
$quy = Powner::select('powners.ownerid', 'powners.oname')->distinct()
->selectRaw('count(pets.petid) as CountOfpetid')
->leftJoin('pets', 'powners.ownerid', '=', 'pets.ownerid')
->groupby('powners.ownerid')
->orderby('powners.oname')
->get();
Just example, and see this for db facade:
https://laracasts.com/discuss/channels/laravel/sql-native-to-query-builder
or
https://laracasts.com/discuss/channels/guides/getpdo-usage
You have to realize, some queries take trial and error to figure out.
As example see this post and the time it took to work out:
https://laracasts.com/discuss/channels/eloquent/orderby-computed-related-attribute