I'm trying to get the present (P) student status. Then I want to count the total students present within a month. Unfortunately, my code doesn't work properly.
$jan_count = Attendance::with(['level', 'student'])
->where(['level_id' => $id, 'status' => 'P'])
->whereMonth('days', '01')
->count()
->get()
->groupBy('student_id');
yes it will because its not a valid Query try the below Code
$jan_count = Attendance::with(['level','student'])
->where([
['level_id' ,'=', $id],
['status','=','P']
])
->whereMonth('days', '01')
->get()
->groupBy('student_id');
If any issues kindly Comment Below
Use only count function for get count if you get result assign one variable and get result
$jan_count = Attendance::with(['level','student'])
->where([
['level_id' ,'=', $id],
['status','=','P']
])
->whereMonth('days', '01')
->groupBy('student_id')
->count();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.