Jul 21, 2020
0
Level 1
Export excel file using Maatwebsite
Hello, I have a problem with export excel file using Maatwebsite , iam trying to get count of multiple values and group them by id.
this is my query :
$data = DB::table('posts')
->select('employee_id',DB::raw('COUNT(statut = 1) AS condition_1'),DB::raw('COUNT(statut = 2) AS condition_2'))
->groupBy('employee_id')
->orderBy('employee_id');
return $data;
this the controller :
public function export(Request $request)
{
return Excel::download(new PostsExport(), 'Filename.xlsx');
}
the problem is when i export the file, it count just first condition and all other is a copy of it. can any one help, thank you.
Please or to participate in this conversation.