Answers for "sort by number of views descending laravel"

PHP
0

sort by number of views descending laravel

$posts = Post::select(DB::raw('posts.*, count(*) as `aggregate`'))
    ->join('views', 'posts.id', '=', 'views.post_id')
    ->groupBy('post_id')
    ->orderBy('aggregate', 'desc')
    ->get();
Posted by: Guest on April-13-2021

Code answers related to "sort by number of views descending laravel"

Browse Popular Code Answers by Language