refactor: Simplify course selection options in schedule form by directly retrieving all courses and adding options limit.

This commit is contained in:
Yoga Pangestu 2026-03-11 07:42:15 +07:00
parent 7a9cb7fed9
commit 01b3627cc2

View File

@ -156,16 +156,7 @@ public function scheduleFormSchema(): array
Select::make('course_id')
->label('Mata Kuliah')
->options(function () {
$user = auth()->user();
$lecturer = $user->lecturer;
if ($lecturer) {
$courses = Course::getOptionsForLecturer($lecturer);
} else {
$courses = Course::all();
}
return $courses
return Course::all()
->groupBy('semester')
->mapWithKeys(function ($courses, $semester) {
return [
@ -177,7 +168,8 @@ public function scheduleFormSchema(): array
->searchable()
->live()
->required()
->columnSpanFull(),
->columnSpanFull()
->optionsLimit(100),
Grid::make(3)
->schema([