Advice: How to access "related" models in a different database
I am using
stancl/tenancy
to provide a multi-tenant application with multi-database tenancy.
I have two panels, one for Admins, and one for Tenants. From the Admin panel I have access to a Tenant Resource, however, I'd like to then be able to access the "related" models from that Tenant's database:
This can be achieved by running a query within the Tenant's context, with either
i'm looking for some advice on how best to achieve this, "The Filament Way". Do I:
- Create a Page, within the TenantResource /tenant/{id}/user
. Then use "custom" infolists on these pages?
- Is there a way to create a "faux" RelationshipManger
?
- another way I'm ignorant to?
thanks, and sorry for the "advice" question, I'm fairly new to Filament world and just wanna make sure I'm not missing anything along the journey.4 Replies
Multi database tenancy is very tricky.
I'd consider whether that is really what you need, these days they are falling out of fashion.
Or, assuming your using a proper database engine, if you are using UUID, what about a single database that collects the views from the others into single virtual tables and build the relationships to there.
Alternatively, can you not just tenant the Admin user?
We have "good" reasons to opt for this architecture, and we have user/tenant impersonation.
The UX would be vastly improved with the above approach though
I think you’re loosing the scope of what a tenant is in a multi db setup. The entire point of multi db is that they can’t access each other. It’s a security safeguard.
I don't want them to access each other. I want to access them from the central app.