{{-- Case 1: Holiday --}}
@if (in_array($formattedDate, $holidays))
Holiday
@php $holidaysFrontend++; @endphp
@else
{{-- Case 2: Attendance Found --}}
@php
$attendanceRecord = collect($attendances)->first(function ($att) use ($formattedDate) {
return \Carbon\Carbon::parse($att['date_of_attendance'])->format('Y-m-d') === $formattedDate;
});
@endphp
@if ($attendanceRecord)
@if ($attendanceRecord['is_present'] == 1)
Present
@php $totalPresent++; @endphp
@else
Absent
@php $totalAbsent++; @endphp
@endif
{{-- Case 3: Weekend but NOT in working weekends --}}
@elseif ($carbonDate->isWeekend() && !in_array($formattedDate, $weekends))
Weekend
@php $weekendsFrontend++; @endphp
{{-- Case 4: Not Marked (including working weekends) --}}
@else