Eloquent is great but it can be very tricky to get right when the query gets more complex.
What I usually do is create a database view in a migration then run eloquent against that.
Here is an example from one of my applications
DB::statement(
"CREATE OR REPLACE VIEW book_views AS
SELECT
(SELECT GROUP_CONCAT(a.id ORDER BY a.id SEPARATOR ',')
FROM authors a, author_books ab
WHERE a.id = ab.author_id
AND ab.book_id = b.id) author_id,
(SELECT GROUP_CONCAT(concat(a.last_name, ', ', a.first_name)
ORDER BY a.last_name, a.first_name SEPARATOR ' & ')
FROM authors a, author_books ab
WHERE ab.author_id = a.id
AND ab.book_id = b.id) author_name,
b.id book_id,
b.title,
(SELECT ROUND(AVG(s.score), 1)
FROM scores s
WHERE s.item_id = b.id
AND media_type_id = 1) rating,
b.series,
b.part,
b.released,
g.id genre_id,
g.genre,
f.id format_id,
f.format,
CASE series
WHEN 'Standalone'
THEN b.released
ELSE (SELECT MIN(bi.released)
FROM books bi
WHERE bi.series = b.series)
END series_started
FROM books b,
genres g,
formats f
WHERE b.genre_id = g.id
AND b.format_id = f.id"
);
Then I query it like so
$books = BookView::orderBy('author_name')
->orderBy('series_started')
->orderBy('part')
->orderBy('released')
->orderBy('title')
->get();