Action::make('Edit Section')
->modalWidth('md')
->fillForm(fn(Section $record) => [
'name' => $record->name,
'instructor_id' => $record->instructor_id,
'course_id' => $record->course_
])
->schema([
Select::make('instructor_id')
->label('Instructor')
->relationship(
'instructor',
modifyQueryUsing: fn($query) => $query->whereInstructorDepartment(auth()->user()->instructor- >department_id))
->getOptionLabelFromRecordUsing(fn($record) => $record->full_name)
->searchable()
->preload()
->required(),
Select::make('course_id')
->label('Course')
->options(
fn() => Course::whereDepartment(auth()->user()->instructor->department_id)
->pluck('code', 'id')
->toArray()
)
->searchable()
->preload()
->required(),
])
->action(function (array $data, Section $record) {
$record->update($data);
Notification::make()
->title('Section updated successfully')
->success()
->send();
})
Action::make('Edit Section')
->modalWidth('md')
->fillForm(fn(Section $record) => [
'name' => $record->name,
'instructor_id' => $record->instructor_id,
'course_id' => $record->course_
])
->schema([
Select::make('instructor_id')
->label('Instructor')
->relationship(
'instructor',
modifyQueryUsing: fn($query) => $query->whereInstructorDepartment(auth()->user()->instructor- >department_id))
->getOptionLabelFromRecordUsing(fn($record) => $record->full_name)
->searchable()
->preload()
->required(),
Select::make('course_id')
->label('Course')
->options(
fn() => Course::whereDepartment(auth()->user()->instructor->department_id)
->pluck('code', 'id')
->toArray()
)
->searchable()
->preload()
->required(),
])
->action(function (array $data, Section $record) {
$record->update($data);
Notification::make()
->title('Section updated successfully')
->success()
->send();
})