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:
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:
1. In the table, role does not display.
2. 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).
3. When editing a user, the form loads name and email, but does not load the current role from the pivot table.
How can I correctly display, load, and save a pivot field (role) in this UserResource with multi-tenancy enabled?2 Replies
I couldn’t figure out a clean solution, so I ended up moving Users management from a dedicated resource into the Company resource (the tenant in my case) using a relation manager.
Inside the Company resource, I now display the related users so they can be managed directly.
The previous UX felt awkward, users had to click Companies (which only showed the current tenant), open its details, and only then manage the users.
Instead, I added a user management section directly to the Tenant Profile page. Now, when a user visits tenant settings, they see the tenant’s info and, right below it, the related users. This feels much more natural and streamlined.
I found the way to implement it here:
https://www.answeroverflow.com/m/1250377468712583220
Add Relation Manager to EditTenantProfile - Filament
How can I add a RelationManager to the EditTenantProfil page? I tried adding getRelations() to the EditTeamProfile, but it doesn't show up. I figure something about a custom view, but I am not that experienced in custom views?
I have a TeamResource with Create/Edit, where the UserRelationManager works perfectly, but not on the tenant edit prof...
i solved this by creating a model for my pivot to
https://laravel.com/docs/12.x/eloquent-relationships#defining-custom-intermediate-table-models
and a seperate resource for my pivot model.
Below my implementation
Pivot model
Companies model
User modal
Eloquent: Relationships - Laravel 12.x - The PHP Framework For Web ...
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.