@php $base = array_filter([ 'view' => $mode === 'week' ? 'week' : null, 'month' => $mode === 'month' ? $month->format('Y-m') : null, 'date' => $mode === 'week' ? $anchor->toDateString() : null, 'employee' => $employeeFilter, ], fn ($v) => $v !== null && $v !== ''); $url = fn (array $over = []) => route('schedule.index', array_filter(array_merge($base, $over), fn ($v) => $v !== null && $v !== '')); $prev = $mode === 'week' ? $url(['date' => $anchor->copy()->subWeek()->toDateString()]) : $url(['month' => $month->copy()->subMonth()->format('Y-m')]); $next = $mode === 'week' ? $url(['date' => $anchor->copy()->addWeek()->toDateString()]) : $url(['month' => $month->copy()->addMonth()->format('Y-m')]); $today = $mode === 'week' ? $url(['date' => null]) : $url(['month' => null]); $title = $mode === 'week' ? $start->format('d.m').' – '.$end->format('d.m.Y') : $month->format('F Y'); $in = 'rounded-md border-gray-300 text-sm'; @endphp

Staff schedule

Employees
@if (session('status') && ! $day)
{{ session('status') }}
@endif
{{ $title }}
@foreach (collect($base)->except('employee') as $k => $v)@endforeach

Click a day to add or edit who is working.

@if ($mode === 'month')
@foreach (['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] as $d)
{{ $d }}
@endforeach
@endif
@for ($d = $start->copy(); $d->lte($end); $d->addDay()) @php $list = $byDay[$d->toDateString()] ?? collect(); $inMonth = $mode === 'week' || $d->month === $month->month; $limit = $mode === 'week' ? 99 : 3; @endphp
{{ $mode === 'week' ? $d->format('D d.m') : $d->day }}
@foreach ($list->take($limit) as $s)
{{ $s->employee->name }}@if ($mode === 'week')
{{ $s->timeLabel() }}@endif
@endforeach @if ($list->count() > $limit)
+{{ $list->count() - $limit }} more
@endif
@endfor
{{-- Day panel --}} @if ($day) @php $busy = $dayShifts->pluck('employee_id')->all(); $free = $employees->reject(fn ($e) => in_array($e->id, $busy)); $closeUrl = $url(['day' => null]); $presets = [['08:00', '16:00'], ['09:00', '17:00'], ['09:00', '18:00'], ['10:00', '19:00']]; @endphp
{{ $day->format('l, d.m.Y') }}
✕
@if (session('status'))
{{ session('status') }}
@endif @if ($errors->any())
{{ $errors->first() }}
@endif {{-- 1. Who works this day --}}

Working this day ({{ $dayShifts->count() }})

@forelse ($dayShifts as $s)
{{ $s->employee->name }} {{ $s->timeLabel() }}
@csrf @method('DELETE')
@if ($s->note)
{{ $s->note }}
@endif
@csrf @method('PUT') {{ $s->employee->name }} –
@empty

Nobody yet.

@endforelse
{{-- 2. Add people --}}
@csrf

Who is coming?

@foreach ($free as $e) @endforeach
@if ($free->isEmpty() && $employees->isNotEmpty())

Everyone in the list is already working this day.

@endif

What hours?

@foreach ($presets as [$a, $b]) @endforeach
or –
@endif