Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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');
Source by laracasts.com #
 
PREVIOUS NEXT
Tagged: #laravel #groupby #latest
ADD COMMENT
Topic
Name
9+1 =