James
James
FFilament
Created by James on 4/1/2024 in #❓┊help
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
FFilament
Created by James on 1/4/2024 in #❓┊help
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:
public function teams() {
return $this->belongsToMany(Team::class, 'members')
->withPivot('role_id');
}
public function teams() {
return $this->belongsToMany(Team::class, 'members')
->withPivot('role_id');
}
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
FFilament
Created by James on 10/21/2023 in #❓┊help
set default value for select
I cannot figure out how to set the default value for a select. I've tried both:
Select::make('status')
->options(StatusEnum::class)
->default(StatusEnum::DRAFT)
Select::make('status')
->options(StatusEnum::class)
->default(StatusEnum::DRAFT)
and
Select::make('status')
->options(StatusEnum::class)
->default(StatusEnum::DRAFT->value)
Select::make('status')
->options(StatusEnum::class)
->default(StatusEnum::DRAFT->value)
Neither seems to actually set the default value.
11 replies