James
What should I be testing?
This isn't necessarily specific to Filament, but also I feel like this is even harder in a Filament app. At least I find myself thinking traditional testing of fill out a form, submit, check that its in the database it too much because it gets into testing Filaments internal logic? Any videos or articles with some practical walkthoughs of what and how to test a Filament app would be great if there are any someone could recommend.
6 replies
Users Resource on Multitenant Setup with Pivot Data
So I have a User resource on a panel with multitenancy but I want to only show users who are part of the same tenant (Team model).
My relationship for the tenant looks like this:
Adding
protected static ?string $tenantOwnershipRelationshipName = 'teams';
seems to have done that part just fine. But my pivot table, using a Member model, stores a third relation to a Role model.
How can I get the role name to display as a column on the Users table?
I was playing around with using a custom text column with a state function to get the value like so:
$user->teams->first()->pivot->role->name
This kinda works, except for instead of just grabbing the first team for the user I need a good way to grab the current team. I feel like there should be an easy way to do this but I am not sure with such a complex relationship.15 replies