Is it possible to order by the total count of multiple tables?
问题 I can't get this query to work! return Post::selectRaw('likes_count + comments_count as total_count') ->withCount(['likes', 'comments']) ->groupBy('posts.id') ->orderByDesc('total_count') ->paginate(); It works this way below but I want all the counts and something performant! return Post::leftJoin('likes', function ($join) { $join->on('posts.id', 'likes.likable_id') ->where('likes.likable_type', (new Post)->getMorphClass()); })->leftJoin('comments', function ($join) { $join->on('posts.id',