User BelongsToMany Groups pivot table with additional "Role" field, how to select role?
I have a
users
table and a groups
table, with a many to many relationship between them, using the group_user pivot table, which contains a role
field, which can be interpreted as a group_role
.
I have added the groups field to my UserResource form like this:
*The roles field in the table is for global user roles, and unrelated to my issue.
I need a way to assign a group_role
to my users within each group they belong to, what is the filament way to do this?Solution:Jump to solution
It seemed like the relation manager was the filament way to do this. I added the --attach flag to my php artisan command when creating the relation manager, then removed the create and delete methods so that I would only be able to edit, attach, and detach relations.
For others in the same situation, you can find all information about this here:
https://filamentphp.com/docs/3.x/panels/resources/relation-managers...
1 Reply
Solution
It seemed like the relation manager was the filament way to do this. I added the --attach flag to my php artisan command when creating the relation manager, then removed the create and delete methods so that I would only be able to edit, attach, and detach relations.
For others in the same situation, you can find all information about this here:
https://filamentphp.com/docs/3.x/panels/resources/relation-managers