Level 75
Cast to int if needed. But in php should just work as integer anyway unlike some languages.
Are you getting expected results.
2 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How do i get the present_count value from the query below as an integer?
$attendance = Attendance::selectRaw('count(present) as present_count')
->whereMonth('date', $month)
->whereYear('date', $year)
->where('staff_id', $request->input('user_id'))
->get()->toArray();
If you want $attendance as the integer result only:
$attendance = Attendance::whereMonth('date', (int) $month)
->whereYear('date', (int) $year)
->where('staff_id', $request->input('user_id'))
->count('present');
Please or to participate in this conversation.