mercredi 18 décembre 2019

How to GroupBy in Query Laravel 5.8

I want to grouping table_name in my data using laravel query builder. But when i run it, the result still not grouping. This is my data :

enter image description here

And this is my query to do this:

$data['list_module'] = DB::table('roles as a')
                         ->leftJoin('permission_role as b', 'a.id', 'b.role_id')
                         ->leftJoin('permissions as c', 'b.permission_id', 'c.id')
                         ->where('a.id', $id)
                         ->select('c.key','c.table_name')
                         ->groupBy('c.key', 'c.table_name')
                         ->orderBy('c.table_name', 'DESC')
                         ->get();


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire