© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
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 ?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Searchable by pivot name
FilamentFFilament / ❓┊help
14mo ago
Sort by pivot date
FilamentFFilament / ❓┊help
2y ago
Custom Filter - Multi-Select on Pivot
FilamentFFilament / ❓┊help
15mo ago
Filter by range
FilamentFFilament / ❓┊help
3y ago