Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

get popular models on laravel

//Get popular posts on laravel based on comments and likes

$posts = Post::withCount('comments','likes')->orderBy(DB::raw('comments_count + likes_count'),'DESC')->get();
 
PREVIOUS NEXT
Tagged: #popular #models #laravel
ADD COMMENT
Topic
Name
6+8 =