Select::make('matieres')
->label('Matière(s)')
->multiple()
->relationship('matieres', 'nom')
->options(Matiere::whereHas('sessions', function ($Query) {
$Query->where('session_id', '=', Filament::getTenant()->id);
})->get()->sortBy(function ($matiere) {
return $matiere->nom; // Sort by the accessor value
})
->mapWithKeys(function ($matiere) {
return [$matiere->id => $matiere->nom]; // Uses the getNomAttribute() accessor
}))
->preload()
->live()
-required()
Select::make('matieres')
->label('Matière(s)')
->multiple()
->relationship('matieres', 'nom')
->options(Matiere::whereHas('sessions', function ($Query) {
$Query->where('session_id', '=', Filament::getTenant()->id);
})->get()->sortBy(function ($matiere) {
return $matiere->nom; // Sort by the accessor value
})
->mapWithKeys(function ($matiere) {
return [$matiere->id => $matiere->nom]; // Uses the getNomAttribute() accessor
}))
->preload()
->live()
-required()