F
Filament13mo ago
Arnaud

Filter by pivot

Hello, I'm looking for a way to filter a table by pivot column. I'm using it inside a full Filament v3 admin panel. For exemple, I have Users and Teams. They are linked by a pivot table with three columns : - user_id - team_id - role When I would like to update the baseQuery :
$query->whereHas('teams', function ($query) use ($role) {
$query->where('team_user.role', $role);
});
$query->whereHas('teams', function ($query) use ($role) {
$query->where('team_user.role', $role);
});
I got an error message :
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'role' in 'where clause'
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'role' in 'where clause'
Because in my select filters make method I have put 'role'. I've tried so far : - make('team.role') - make('teams.pivot.role') ... In my models, I have correctly set-up withPivot('role') How to filter by pivot column ?
1 Reply
Arnaud
ArnaudOP13mo ago
Up
Want results from more Discord servers?
Add your server