Reputation: 957
Although I have 3 different teacher reports on the table and all the dates are same, i can only get last teacher's report
$report = DB::table('users')
->join('classreports', 'classreports.teacherId', '=', 'users.id')
->where('classreports.classId', '=', Input::get('classId'))
->where('classreports.reportDate', '=', $reportDate)
->groupBy('classreports.reportDate')
->select('users.fullName', 'classreports.reportDate', DB::raw('group_concat(classreports.report) as report'))
->get();
return json_encode($report);
How can i get all teacher's report?
Thanks.
Upvotes: 0
Views: 474
Reputation: 1699
You can try this
->groupBy('classreports.teacherId','classreports.reportDate')
Can group by teacherID
and reportDate
Upvotes: 1