negro
Explore posts from serversfilament many to many
and this class CreateStudent extends CreateRecord
{
protected static string $resource = StudentResource::class;
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['matricule'] = '122';
$data['academic_id'] = 12;
return $data;
}
}
19 replies
filament many to many
student resource form public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make('Information Personnel Apprenant')
->schema([
Forms\Components\TextInput::make('fname')
->label('Nom')
->autofocus()
->required()
->maxLength(255)
->autocapitalize(),
Forms\Components\TextInput::make('lname')
->label('Prenom')
->maxLength(255)
->autocapitalize(),
Forms\Components\Radio::make('sexe')
->options([
1 => 'Homme',
0 => 'Femme',
])
->boolean()
->inline()
->default(1)
->required(),
Forms\Components\DatePicker::make('born_at')
->label('Date de Naissance')
->required(),
Forms\Components\TextInput::make('born_place')
->label('Lieu de naissance')
->required()
->maxLength(255),
Forms\Components\TextInput::make('quarter')
->label('Quartier Habitation')
->maxLength(255)
->required()
])
->columns(2),
]);
}
19 replies
filament many to many
function in my student model: public function classrooms() {
return $this->belongsToMany(Classroom::class)->withPivot('academic_id');
}
function in my classroom model: public function students() {
return $this->belongsToMany(Student::class,)->withPivot('academic_id');
}
19 replies