@forelse ($take as $student) {{ $student['user']['username']??"N/A" }} {{ $student->user->mobile ?? 'N/A' }} {{ $student->roll_no ?? 'N/A' }} @php $todayAttendance = ''; // Get the first attendance for today $inTimeAttendance = ''; @endphp @if ($student->attendances->isNotEmpty()) @php $todayAttendance = collect($student->attendances) ->where('attendance_type', '1') ->sortBy('attendance_time') ->first(); @endphp @endif @if ($student->attendances->isNotEmpty()) @php $todayAttendance = collect($student->attendances) ->where('attendance_type', '2') ->sortByDesc('attendance_time') ->first(); @endphp @endif Present Absent @empty No students found for the selected filters. @endforelse