© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3mo ago•
1 reply
loading_personality

Select filter in QueryBuilder for nested relationship

Hi everyone,

I’m using FilamentPHP with
QueryBuilder::make()
QueryBuilder::make()
and I want to create a filter similar to the
RelationshipConstraint
RelationshipConstraint
example below:

RelationshipConstraint::make('client')
    ->icon('hugeicons-user-multiple')
    ->multiple()
    ->selectable(
        IsRelatedToOperator::make()
            ->titleAttribute('public_name')
            ->label(__('invoice::main.list.client'))
            ->searchable()
            ->preload()
            ->multiple()
    ),
RelationshipConstraint::make('client')
    ->icon('hugeicons-user-multiple')
    ->multiple()
    ->selectable(
        IsRelatedToOperator::make()
            ->titleAttribute('public_name')
            ->label(__('invoice::main.list.client'))
            ->searchable()
            ->preload()
            ->multiple()
    ),


However, my scenario is a bit more complex because I need to filter through two relationships.

I have the following relationships defined in my model:

public function subscription()
{
    return $this->morphOne(config('soulbscription.models.subscription'), 'subscriber')->ofMany('started_at', 'MAX');
}

public function plan()
{
    return $this->belongsTo(config('soulbscription.models.plan'));
}
public function subscription()
{
    return $this->morphOne(config('soulbscription.models.subscription'), 'subscriber')->ofMany('started_at', 'MAX');
}

public function plan()
{
    return $this->belongsTo(config('soulbscription.models.plan'));
}


I want to filter by plan ID and display the plan name in the filter dropdown.

What’s the cleanest way to achieve this with
RelationshipConstraint
RelationshipConstraint
in Filament?

Any guidance or examples would be greatly appreciated!
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

[QueryBuilder] How can you filter a multi relationship?
FilamentFFilament / ❓┊help
2y ago
Is it possible to use a nested relationship in a RelationshipConstraint filter?
FilamentFFilament / ❓┊help
3y ago
QueryBuilder Filter returns nothing
FilamentFFilament / ❓┊help
3y ago
Select Filter with nested relation won't filter
FilamentFFilament / ❓┊help
2y ago