Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filamentβ€’3y agoβ€’
4 replies
Sesh

How to use deep relations in filters in the V3 Table Builder?

Is there a way to use deep relations in filters in V3? I have the following relation:

News => belongsToMany => players => belongsTo => playerCategory

Which is defined in the News Model like this (and works):

public function playerCategories()
{
   return $this->hasManyDeepFromRelations($this->players(), (new Player())->playerCategory());
}
public function playerCategories()
{
   return $this->hasManyDeepFromRelations($this->players(), (new Player())->playerCategory());
}


I want to add a Filter for playerCategories in the News table builder component. I tried this:

SelectFilter::make('playerCategories')
         ->label(__('Player Categories'))
         ->preload()
         ->relationship(playerCategories', 'name_en')
         ->multiple(),
SelectFilter::make('playerCategories')
         ->label(__('Player Categories'))
         ->preload()
         ->relationship(playerCategories', 'name_en')
         ->multiple(),


And got this error:

Filament\Forms\Components\Select::getRelationship(): Return value must be of type Illuminate\Database\Eloquent\Relations\BelongsTo|Illuminate\Database\Eloquent\Relations\BelongsToMany|Znck\Eloquent\Relations\BelongsToThrough|null, Staudenmeir\EloquentHasManyDeep\HasManyDeep returned
Filament\Forms\Components\Select::getRelationship(): Return value must be of type Illuminate\Database\Eloquent\Relations\BelongsTo|Illuminate\Database\Eloquent\Relations\BelongsToMany|Znck\Eloquent\Relations\BelongsToThrough|null, Staudenmeir\EloquentHasManyDeep\HasManyDeep returned


Does anyone know how to achieve this? Thanks πŸ™
Solution
I don't think
->relationship()
->relationship()
supports HasManyDeep

You have to provide
->options()
->options()
&
->query()
->query()
manually
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to use table filters in getEloquentQuery?
FilamentFFilament / β“β”Šhelp
2y ago
Use Array in Table Builder
FilamentFFilament / β“β”Šhelp
16mo ago
How to use SpatieMediaLibraryFileUpload in the Builder
FilamentFFilament / β“β”Šhelp
6mo ago
How to use "tableSearch" query string in table builder?
FilamentFFilament / β“β”Šhelp
3y ago