Group By Eloquent ORM

前端 未结 3 1366
天涯浪人
天涯浪人 2020-12-10 00:47

I was searching for making a GROUP BY name Eloquent ORM docs but I haven\'t find anything, neither on google.

Does anyone know if it\'s possible ? or sh

3条回答
  •  Happy的楠姐
    2020-12-10 01:23

    Eloquent uses the query builder internally, so you can do:

    $users = User::orderBy('name', 'desc')
                    ->groupBy('count')
                    ->having('count', '>', 100)
                    ->get();
    

提交回复
热议问题