© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
23 replies
Roberto S.

SelectFilter by 2 level relationship

I want to make a SelectFilter by country in a table where I show vehicles.

The data model is as follows:

Vehicle
- id
- name
- place_id

Place
- id
- name
- country_id

Country
- id
- code
- name

That is, a Vehicle belongs to a Place and a Place has a Country.

My current code is as follows, the filter shows it but the changes are not applied:

SelectFilter::make('place.country.code')
    ->label(__('Country'))
    ->options(fn () => Country::pluck('name', 'code')->toArray())
    ->multiple()
    ->searchable()
    ->preload(),
SelectFilter::make('place.country.code')
    ->label(__('Country'))
    ->options(fn () => Country::pluck('name', 'code')->toArray())
    ->multiple()
    ->searchable()
    ->preload(),

Thanks
Solution
https://v2.filamentphp.com/tricks/use-selectfilter-on-distant-relationships

Can you check this article
Filament
Use SelectFilter on distant relationships by Hugh Messenger - Trick...
Filament is a collection of tools for rapidly building beautiful TALL stack apps, designed for humans.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

SelectFilter relationship field
FilamentFFilament / ❓┊help
3y ago
2 level relationship manager
FilamentFFilament / ❓┊help
2y ago
SelectFilter with relationship help...
FilamentFFilament / ❓┊help
2y ago
SelectFilter with relationship query
FilamentFFilament / ❓┊help
2y ago