Level 3
you can try this . it might be error . but i guess you can find something with that code ;)
$attendance = Attendance::with('student', function ($query) {
$query->where('username',$request->name);
})->where('created_at')->count();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Dear Developers, I need to count and specific item from mysql using laravel eloquent query for current month. Like when i will count item it will count only for that month . but I unable to do that . I am just trying to count only but its not working too :(
$attendence= DB::table('students')
->join('attendences', 'attendences.student_username', '=', 'students.username')
->select(
count('attendences.attendence'),
'attendences.created_at'
)->where('username',$request->name)
->get();
I am getting error ""count(): Parameter must be an array or an object that implements Countable""
Please or to participate in this conversation.