Issue displaying & editing pivot field (role) in multi-tenant UserResource
Hi, I’m working on a multi-tenant Laravel Filament app with companies and users in a many-to-many relationship.
The pivot table is company_user and contains a role field.
I’ve set up my UserResource like this:
This correctly filters users to the current tenant.
In my table, I want to show name, email, and role:
name and email display fine, but role does not show.
I expected it to work like how relationship managers handle pivot fields.
Models
User model:
Company model:
Form fields in UserResource:
The problems I’m facing:
The pivot table is company_user and contains a role field.
I’ve set up my UserResource like this:
protected static ?string $tenantOwnershipRelationshipName = 'companies';This correctly filters users to the current tenant.
In my table, I want to show name, email, and role:
name and email display fine, but role does not show.
I expected it to work like how relationship managers handle pivot fields.
Models
User model:
Company model:
Form fields in UserResource:
The problems I’m facing:
- In the table, role does not display.
- When creating a user, Filament inserts data into the pivot table but ignores the value from the role select — it always uses the DB default (member).
- When editing a user, the form loads name and email, but does not load the current role from the pivot table.