From 2253db3a5ec567e6883cf59982a89d4a1e12d8b1 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Sun, 29 Mar 2026 21:29:05 +0700 Subject: [PATCH] feat: filter course options to exclude already scheduled courses while preserving the current selection --- app/Filament/Pages/Information/CourseSchedule/Index.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Filament/Pages/Information/CourseSchedule/Index.php b/app/Filament/Pages/Information/CourseSchedule/Index.php index 0ee46c8..9ff338d 100644 --- a/app/Filament/Pages/Information/CourseSchedule/Index.php +++ b/app/Filament/Pages/Information/CourseSchedule/Index.php @@ -137,9 +137,16 @@ public function scheduleFormSchema(): array ->schema([ Select::make('course_id') ->label('Mata Kuliah') - ->options(function () { + ->options(function ($record) { return Course::query() ->where('semester', app(GeneralSettings::class)->current_semester) + ->where(function ($query) use ($record) { + $query->whereDoesntHave('courseSchedules'); + + if ($record && $record->course_id) { + $query->orWhere('id', $record->course_id); + } + }) ->pluck('name', 'id') ->toArray(); })