F
Filament4mo ago
NolanN

Add tenant scope only to child resource

I'm building a multi-tenant app which has a resource that does not need to be scoped to the tenant. However, on the table I want to list counts of a related resource that should be scoped to the tenant. Is there a way to have a parent without a scope and a child with the tenant scope?
Solution:
For now I'm only adding simplistic data to the table so I was able to solve this by modifying the query of the aggregate columns with something like this: fn (Builder $query) => $query->whereRelation('customer', 'tenant_id', Filament::getTenant()->id),
Jump to solution
3 Replies
NolanN
NolanN4mo ago
Any thoughts?
Solution
NolanN
NolanN4mo ago
For now I'm only adding simplistic data to the table so I was able to solve this by modifying the query of the aggregate columns with something like this: fn (Builder $query) => $query->whereRelation('customer', 'tenant_id', Filament::getTenant()->id),