Search
 
SCRIPT & CODE EXAMPLE
 

PHP

group by laravel

$user_info = DB::table('usermetas')
                 ->select('browser', DB::raw('count(*) as total'))
                 ->groupBy('browser')
                 ->get();
Comment

laravel groupby and latest

//If You want the latest id of records then you can use unique() after get(),
//don't use group by if you use groupBy 
//then you lose your control from id. I hope this is useful for you

myModel::select('id','purch','name','prcvalue')
  ->where('purch','=','10234')
  ->orderBy('prcvalue','DESC')
  ->get()
  ->unique('name');
Comment

PREVIOUS NEXT
Code Example
Php :: php check if string contains url 
Php :: laravel get current route url 
Php :: hide add new link on cpt page 
Php :: notify multiple users laravel 
Php :: string match percentage php 
Php :: adminlte 3 laravel 
Php :: how to see php error log 
Php :: string and number laravel faker 
Php :: pluck laravel 
Php :: php date diff in days 
Php :: if url has certain code then php 
Php :: eloquent get trashed record 
Php :: root composer.json requires php ^7.3 but your php version (8.0.3) does not satisfy that requirement. 
Php :: define int variable in php 
Php :: upload multiple images in php 
Php :: php using composer autoload - own code 
Php :: convert array into , separated string in php 
Php :: how to data save usigng request all laravel 
Php :: wherehas laravel search 
Php :: php include 
Php :: wpml get site url 
Php :: how to get previous date in laravel 
Php :: laravel search 
Php :: cors error angular php 
Php :: php send json post 
Php :: update values in array in php 
Php :: laravel switch 
Php :: laravel except method 
Php :: how to give optional parameter in route 
Php :: wordpress send reset password link inside wp_new_user_notification_email 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =