0

I have the model Student

Student

  • groups : BelongsToMany

and model Group

Group

  • students: HasMany

of course there is a pivot table group_student with

group_id student_id

I am trying, in Filament3, to set up a StudentRelationManager , so that I can add students to a group , with the table (not with select )

I ran this command

php artisan make:filament-relation-manager GroupResource students student_id

and of course added the relation

public static function getRelations(): array
    {
        return [
            RelationManagers\StudentsRelationManager::class
        ];
    }

but the minute a click on edit on a given Group record

I get this enter image description here

which is wrong because the student doesnt belong to just one group, but could be in many, so it doesnt have a group_id, but depends on the pivot table : group_student

Instead of something like this

enter image description here

What I am missing ? how to make it work ? can this be achieved ? I searched but could nt find other than fixing it with selects .

Please advice

bachstein
  • 23
  • 4

1 Answers1

0

so, the answer wat to use the flags associate

 php artisan make:filament-relation-manager GroupResource students student_id --associate
bachstein
  • 23
  • 4