refactor: Simplify course selection options in schedule form by directly retrieving all courses and adding options limit.
This commit is contained in:
parent
7a9cb7fed9
commit
01b3627cc2
@ -156,16 +156,7 @@ public function scheduleFormSchema(): array
|
|||||||
Select::make('course_id')
|
Select::make('course_id')
|
||||||
->label('Mata Kuliah')
|
->label('Mata Kuliah')
|
||||||
->options(function () {
|
->options(function () {
|
||||||
$user = auth()->user();
|
return Course::all()
|
||||||
$lecturer = $user->lecturer;
|
|
||||||
|
|
||||||
if ($lecturer) {
|
|
||||||
$courses = Course::getOptionsForLecturer($lecturer);
|
|
||||||
} else {
|
|
||||||
$courses = Course::all();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $courses
|
|
||||||
->groupBy('semester')
|
->groupBy('semester')
|
||||||
->mapWithKeys(function ($courses, $semester) {
|
->mapWithKeys(function ($courses, $semester) {
|
||||||
return [
|
return [
|
||||||
@ -177,7 +168,8 @@ public function scheduleFormSchema(): array
|
|||||||
->searchable()
|
->searchable()
|
||||||
->live()
|
->live()
|
||||||
->required()
|
->required()
|
||||||
->columnSpanFull(),
|
->columnSpanFull()
|
||||||
|
->optionsLimit(100),
|
||||||
|
|
||||||
Grid::make(3)
|
Grid::make(3)
|
||||||
->schema([
|
->schema([
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user