<?phpnamespace App\Filament\Advisor\Pages;use App\Models\Advisor;use Filament\Forms\Components\TextInput;use Filament\Forms\Components\Wizard;use Filament\Forms\Concerns\InteractsWithForms;use Filament\Forms\Form;use Filament\Notifications\Notification;use Filament\Pages\Page;class ProfileInformation extends Page{ use InteractsWithForms; public ?array $data = []; public Advisor $record; protected static ?string $navigationIcon = 'heroicon-o-credit-card'; protected static string $view = 'filament.advisor.pages.profile-information'; public function mount(): void { $this->record = Advisor::findorFail(auth()->id()); $this->form->fill($this->record->attributesToArray()); } public function form(Form $form): Form { return $form ->schema([ Wizard::make([ Wizard\Step::make('Info') ->schema([ TextInput::make('name'), ]), ]), ]) ->statePath('data') ->model(Advisor::class); } public function save(): void { $data = $this->form->getState(); $this->record->update($data); Notification::make()->success()->title('Saved')->send(); }}
public function englishExams(): BelongsToMany { return $this->belongsToMany(EnglishExam::class, 'english_exam_student'); }
public function students(): BelongsToMany { return $this->belongsToMany(Student::class, 'english_exam_student'); }
Repeater::make('englishExams') ->relationship() ->schema([ Select::make('english_exam_id') ->label('English Exam') ->options(EnglishExam::all()->pluck('title', 'id')) ->required(), TextInput::make('speaking_score') ->label('Speaking Score') ->numeric() ->required(), TextInput::make('reading_score') ->label('Reading Score') ->numeric() ->required(), TextInput::make('writing_score') ->label('Writing Score') ->numeric() ->required(), ]) ->columns(4) ->label('English Exams'),
->authMiddleware([ Authenticate::class, CheckRole::class, ]);
public function handle(Request $request, Closure $next, Role $requiredRole): Response { $userRole = $request->user()->role; if ($userRole !== $requiredRole) { $selfPanelRoute = Filament::getPanel($userRole->value)->getId(); return redirect($selfPanelRoute); } return $next($request); }
Tables\Columns\ToggleColumn::make('status'),Tables\Columns\SelectColumn::make('category_id')