Level 58
Yes, Laravel provides an easier way to achieve this using the withCount method. You can modify the query to include the withCount method on the posts relationship, and then order the results by the comments_count column in descending order. Here's an example:
$user->posts()
->withCount('comments')
->orderBy('comments_count', 'desc')
->get();
This will return a collection of posts for the specified user, ordered by the number of comments each post has in descending order.