feat: filter course options to exclude already scheduled courses while preserving the current selection
This commit is contained in:
parent
0070c6b0b1
commit
2253db3a5e
@ -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();
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user