Filament Tenancy Help
I have a DocumentResource in an app with tenancy. The document can be associated with a Team ID or it can be null to represent a document that can be accessed by all Teams.
How would I then modify the query for the filament table to return the null records on top of the default view which is shown based on current tenancy.
I tried the following thinking I was a Laravel genius but of course this doesn't work when filters are applied.
Would appreciate any help.
4 Replies
Return $query
Didnt help, returned $query, but as soon as I put a filter on the filter doesnt apply properly. Applies fine for records belonging to the team id, but then the table is also full of all null ids instead of also applying filter to those
I had the same idea in my project for some pages. I solved it by adding this in the resource itself:
And then scoping the query in the middleware (applyTenantScopes, also recommended in the docs) Sth like this:
Hope that helps you!
Cheers, I figured it out in a similar way just before you replied. Using the same scopeToTenant set to false, then my query in the table field as above started working