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:Jump to 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),
3 Replies
Any thoughts?
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),
Here is the link to the relevant docs: https://filamentphp.com/docs/3.x/tables/columns/relationships#aggregating-relationships