DB::table(‘table_name’)->groupBy(‘column_name’)->get(); is used for group by condition in laravel.
laravel group by clause Example
We are going to fetch data with groupBy clause in laravel from the table emp.
DB::table('emp')->groupBy('manager_name')->get();
Will Generate the following query.
//Select * from emp group BY ‘manage_name’ ;