@extends('layouts.app') @section('title', 'Homework Board') @section('page-title', 'Homework Board') @section('content')
{{-- Header --}}

Daily Homework

@if(in_array(auth()->user()->role, ['teacher', 'admin'])) Post and manage daily homework for your classes @else View homework assigned by your teachers @endif

@if(in_array(auth()->user()->role, ['teacher', 'admin'])) @endif
{{-- Filters --}}
@if($classes->count() > 1) @endif This Week
{{-- Homework List Grouped by Date --}} @forelse($grouped as $dateKey => $items) @php $d = \Carbon\Carbon::parse($dateKey); $isToday = $d->isToday(); $isYesterday = $d->isYesterday(); $dayLabel = $isToday ? 'Today' : ($isYesterday ? 'Yesterday' : $d->format('l')); @endphp
{{-- Date Header --}}
{{ $d->format('d') }}

{{ $dayLabel }}

{{ $d->format('d M Y') }} · {{ $items->count() }} {{ Str::plural('item', $items->count()) }}

{{-- Homework Cards --}}
@foreach($items as $hw)
{{-- Color bar --}} @php $colors = ['bg-amber-500','bg-blue-500','bg-emerald-500','bg-purple-500','bg-rose-500','bg-cyan-500','bg-orange-500','bg-indigo-500']; $barColor = $colors[$hw->subject_id % count($colors)]; @endphp
{{-- Header --}}
{{ $hw->subject->name ?? '—' }} {{ $hw->class_->full_name ?? '—' }}

{{ $hw->title }}

@if(auth()->id() === $hw->teacher_id || auth()->user()->role === 'admin')
@csrf @method('DELETE')
@endif
{{-- Description --}} @if($hw->description)

{{ $hw->description }}

@endif {{-- Footer --}}
{{ strtoupper(substr($hw->teacher->name ?? '?', 0, 1)) }}
{{ $hw->teacher->name ?? 'Unknown' }}
@if($hw->attachment) File @endif {{ $hw->created_at->format('h:i A') }}
@endforeach
@empty

No homework found

@if(request('date')) No homework posted for {{ \Carbon\Carbon::parse(request('date'))->format('d M Y') }} @else No homework posted in the last 7 days @endif

@endforelse {{-- Pagination --}} @if($homework->hasPages())
{{ $homework->links() }}
@endif
{{-- Post Homework Modal --}} @if(in_array(auth()->user()->role, ['teacher', 'admin'])) {{-- Edit Homework Modal --}} @endif @endsection