@extends('layouts.staff_dashboard') @section('title', 'Add Attendance') @section('content') @php $alreadyMarked = $alreadyMarkedHours ?? []; $markedKeys = array_keys($alreadyMarked); sort($markedKeys, SORT_NUMERIC); $displayDate = !empty($selectedDate) ? \Carbon\Carbon::parse($selectedDate)->format('l, M d, Y') : date('l, M d, Y'); // Normalize numeric hour list [1..courseHours] (handles associative $hoursList [1 => "Hour 1"]) $maxCourseHours = max(1, (int) ($courseHours ?? count($hoursList ?? []) ?: 1)); $numericHours = range(1, $maxCourseHours); $hourFromInt = max(1, min($maxCourseHours, (int) ($hourFrom ?? 1))); $hourToInt = max($hourFromInt, min($maxCourseHours, (int) ($hourTo ?? $hourFromInt))); @endphp
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif
Mark Hourly Attendance

{{ $courseName ?? 'Add Attendance' }}

Select the hour range, toggle Present or Absent for each student, and save in one click.

{{ $displayDate }} Hours {{ $hourFrom }} – {{ $hourTo }} {{ $students->count() }} Students @if(!empty($markedKeys)) Already Marked: H{{ reset($markedKeys) }}–H{{ end($markedKeys) }} @endif
Back to Register
@csrf
@csrf
Present: 0 Absent: 0
@if($students->isEmpty())

No Students Found

No students are enrolled for this course and batch.

@else
@foreach($students as $index => $student) @php $status = $attendanceRecords[$student->id] ?? 'Present'; if (!in_array($status, ['Present', 'Absent'], true)) { $status = 'Present'; } $initial = strtoupper(substr(trim((string) ($student->name ?? 'S')), 0, 1)); @endphp @endforeach
Student Reg No Attendance Status
{{ $initial }} {{ $student->name }}
{{ $student->regno }}
@endif
Saving Attendance...
Please wait a moment
@endsection