@php use App\Filament\Resources\ReservationResource; use App\Models\Reservation; use Illuminate\Support\Carbon; $view = in_array(request('view'), ['month', 'week', 'day'], true) ? request('view') : 'week'; try { $cursor = Carbon::parse(request('date', 'today'))->startOfDay(); } catch (\Throwable $e) { $cursor = Carbon::today(); } $statusColor = fn (string $s) => match ($s) { Reservation::STATUS_ACCEPTED => '#3f9b52', Reservation::STATUS_DECLINED => '#b5453b', default => '#c08a2d', }; if ($view === 'month') { $start = $cursor->copy()->startOfMonth()->startOfWeek(Carbon::MONDAY); $end = $cursor->copy()->endOfMonth()->endOfWeek(Carbon::SUNDAY); $rangeLabel = $cursor->format('F Y'); $unit = 'month'; } elseif ($view === 'week') { $start = $cursor->copy()->startOfWeek(Carbon::MONDAY); $end = $cursor->copy()->endOfWeek(Carbon::SUNDAY); $rangeLabel = $start->format('d M').' – '.$end->format('d M Y'); $unit = 'week'; } else { $start = $cursor->copy(); $end = $cursor->copy(); $rangeLabel = $cursor->format('l, d F Y'); $unit = 'day'; } $byDate = Reservation::with('experience') ->whereBetween('reservation_date', [$start->toDateString(), $end->toDateString()]) ->orderBy('reservation_time') ->get() ->groupBy(fn ($r) => $r->reservation_date->toDateString()); $link = fn (string $v, string $d) => url()->current().'?view='.$v.'&date='.$d; $prev = $cursor->copy()->sub($unit, 1)->toDateString(); $next = $cursor->copy()->add($unit, 1)->toDateString(); $today = Carbon::today()->toDateString(); $navBtn = 'display:inline-flex;align-items:center;justify-content:center;padding:.4rem .7rem;border:1px solid var(--gray-200,#e5e7eb);border-radius:.5rem;font-size:.8rem;text-decoration:none;color:inherit;background:var(--gray-50,#f9fafb);'; $chip = 'display:block;margin-top:3px;padding:2px 6px;border-radius:5px;color:#fff;font-size:.68rem;line-height:1.3;text-decoration:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;'; @endphp
Today {{ $rangeLabel }}
@foreach(['day' => 'Day', 'week' => 'Week', 'month' => 'Month'] as $v => $label) {{ $label }} @endforeach
@if($view === 'month')
@foreach(['Mon','Tue','Wed','Thu','Fri','Sat','Sun'] as $d)
{{ $d }}
@endforeach @php $day = $start->copy(); @endphp @while($day <= $end) @php $key = $day->toDateString(); $items = $byDate[$key] ?? collect(); $isOther = $day->month !== $cursor->month; $isToday = $key === $today; @endphp
{{ $day->day }}
@foreach($items as $r) {{ $r->reservation_time->format('H:i') }} {{ $r->name }} @endforeach
@php $day->addDay(); @endphp @endwhile
@elseif($view === 'week')
@php $day = $start->copy(); @endphp @while($day <= $end) @php $key = $day->toDateString(); $items = $byDate[$key] ?? collect(); $isToday = $key === $today; @endphp
{{ $day->format('D d') }}
@forelse($items as $r) {{ $r->reservation_time->format('H:i') }} · {{ $r->name }} · {{ $r->guests }}p @empty
@endforelse
@php $day->addDay(); @endphp @endwhile
@else
@php $items = $byDate[$cursor->toDateString()] ?? collect(); @endphp @forelse($items as $r) {{ $r->reservation_time->format('H:i') }} {{ $r->name }} · {{ $r->guests }} guests @if($r->experience) · {{ $r->experience->slug }} @endif {{ $r->status }} @empty

No reservations on this day.

@endforelse
@endif