Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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();
Comment

PREVIOUS NEXT
Code Example
Php :: laravel migration column types 
Php :: php get multiple url parameters 
Php :: orderby total sales woocommerce 
Php :: Corsair K70 RGB MK.2 
Php :: get_the_terms 
Php :: install bcmath php 7.3 ubuntu 
Php :: php select using prepared statements 
Php :: epoch conversion php 
Php :: use session in laravel 
Php :: Drupal 8 custom form image field 
Php :: flatten in array php 
Php :: Laravel - Add conditional where clause in query 
Php :: laravel admin panel free package 
Php :: php check if day in month 
Php :: PHP rtrim — Strip whitespace (or other characters) from the end of a string 
Php :: transient wp 
Php :: php get all days between two dates 
Php :: laravel not run test 
Php :: laravel validate change password 
Php :: copy file in php 
Php :: curl download progress bar php 
Php :: cf7 remove p tags 
Php :: php max 
Php :: twig to pdf 
Php :: laravel auth sha-1 
Php :: hummingbird remove caching specific page php 
Php :: wpdb get column 
Php :: php md5 password is insecure 
Php :: send data with href 
Php :: install pdo mysql in alpine-apache php 5.6 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =