SELECT book_id, COUNT(*) AS likes
FROM likes_books
GROUP BY book_id
ORDER BY likes DESC
LIMIT 5;
$likes = DB::table('likes_books')
->select('book_id', DB::raw('COUNT(*) as likes'))
->groupBy('book_id')
->orderByDesc('likes')
->limit(5)
->get();
DB::table('likes_books')
используете модель(вместо LikeBook своё название) LikeBook::select....