@php $totalPresent = 0; $totalAbsent = 0; $totalNotMarked = 0; $holidaysFrontend = 0; $weekendsFrontend = 0; @endphp

Attendance Report



@foreach ($dateRange as $datenew) @php $carbonDate = \Carbon\Carbon::create($datenew); $formattedDate = $carbonDate->format('Y-m-d'); $status = ''; @endphp {{-- Case 1: Holiday --}} @if (in_array($formattedDate, $holidays)) @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) @php $totalPresent++; @endphp @else @php $totalAbsent++; @endphp @endif {{-- Case 3: Weekend but NOT in working weekends --}} @elseif ($carbonDate->isWeekend() && !in_array($formattedDate, $weekends)) @php $weekendsFrontend++; @endphp {{-- Case 4: Not Marked (including working weekends) --}} @else @php $totalNotMarked++; @endphp @endif @endif @endforeach
Date Present Absent
{{ $carbonDate->format('d M Y') }} Holiday Present Absent Weekend Not Marked