Select filter in QueryBuilder for nested relationship

Hi everyone, I’m using FilamentPHP with QueryBuilder::make() and I want to create a filter similar to the 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 in Filament?
Any guidance or examples would be greatly appreciated!
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?