📜  按 laravel 分组 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:35.741000             🧑  作者: Mango

代码示例4
//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');