© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•11mo ago•
5 replies
Illizian

Advice: How to access "related" models in a different database

I am using
stancl/tenancy
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
$tenant = // The current Tenant Model

// and then
tenancy()->initialize($tenant);
User::query();

// or:
// @var $user ?User
$users = null
$tenant->run(function () use ($users) {
    $users = User::query();
});
$tenant = // The current Tenant Model

// and then
tenancy()->initialize($tenant);
User::query();

// or:
// @var $user ?User
$users = null
$tenant->run(function () use ($users) {
    $users = User::query();
});


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
/tenant/{id}/user
. Then use "custom" infolists on these pages?
- Is there a way to create a "faux"
RelationshipManger
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.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Searchable for models/relationships with different database connections
FilamentFFilament / ❓┊help
2y ago
Editing related models in their own Resource
FilamentFFilament / ❓┊help
2y ago
Different ways to list related records
FilamentFFilament / ❓┊help
3y ago
How can I save different data in one form to different databases?
FilamentFFilament / ❓┊help
3y ago