@php $isEdit = $mode === 'edit'; $pageTitle = $isEdit ? 'Edit Jadwal' : 'Tambah Jadwal'; $action = $isEdit ? route('admin.schedules.update', $schedule) : route('admin.schedules.store'); $selectedDays = old('active_days', $schedule->exists ? $schedule->details->pluck('day')->unique()->toArray(): []); @endphp
@csrf @if ($isEdit) @method('PUT') @endif
@if ($errors->any())
{{ $errors->first() }}
@endif
@foreach ($days as $day) @endforeach
@foreach ($days as $day) @php $existingDetails = ($detailsByDay[$day] ?? collect())->sortBy('order_number')->values(); $oldDetails = old("details.$day"); $slotCount = is_array($oldDetails) ? count($oldDetails) : $existingDetails->count(); $slotCount = max(1, $slotCount); @endphp

{{ $day }}

@for ($slot = 0; $slot < $slotCount; $slot++) @php $existing = $existingDetails->get($slot); @endphp
Mapel {{ $slot + 1 }}
material_name) }}" placeholder="Materi khusus / ujian" class="h-10 rounded-md border border-slate-300 bg-white px-3 text-sm outline-none focus:border-blue-950 focus:ring-2 focus:ring-blue-950/10">
@endfor
@endforeach