F
Filamentβ€’11mo ago
SirFat

Support for non-tenant managed resources and pages in a multi-tenant implementation

Hiya! I've managed to get multi-tenant up and going, which is fantastic, where a tenant is required. I'm still stuck with the following How do I recreate a new filament-page which is not filtered by tenant? * I have a 'page' which is auto-loaded by the AdminPanelProvider. This by default works, when I click 'Register new client' - the URL building process must be different, as I receive
Missing required parameter for [Route: filament.admin.pages.helix] [URI: admin/{tenant}/helix] [Missing parameter: tenant].
Missing required parameter for [Route: filament.admin.pages.helix] [URI: admin/{tenant}/helix] [Missing parameter: tenant].
Even though on the navigation itself, I can see the tenant parameter being passed along. It is like the register page is trying to build the navigation for itself from a different relative perspective? The page (helix) in this case is just a page and is not bound to an Eloquent model, either. * I have an Eloquent model which is actually reference data. It is shared data (like country or email-address-type). The records are not intended to be filtered by tenant, nor will a tenant be managing the data (I will protect administration of this data via Laravel Pennant and permissions. I receive:
[App\Models\Country] does not have a relationship named [client]. You can change the relationship being used by passing it to the [ownershipRelationship] argument of the [tenant()] method in configuration
[App\Models\Country] does not have a relationship named [client]. You can change the relationship being used by passing it to the [ownershipRelationship] argument of the [tenant()] method in configuration
Solution:
For now, that's the only way to do this πŸ™‚ Other ways are hacky and does not fully work 100% of the time
Jump to solution
8 Replies
SirFat
SirFatβ€’11mo ago
I presume there is existing logic that is meant to accommodate this, or perhaps it's architected in a way that the 'tenant-based' area is separate from a 'core super-user admin' area. I'm trying to keep everything isolated to one environment where possible. as a further clarification: b ecause it isn't just limited to 'resources' - general 'pages' appear afflicted by the same issue, at least when processed like the livewire 'register you client' starting point is used. You can see the behaviour here: https://development.asmorphic.com/admin/ user admin@example.com pwd 12345678 (don't worry, no sensitive info there) You'll see that if you click 'Verizon' or 'Helix' the interface component (Livewire in the case of Verizon) - but if you select the admin dropdown and select 'register new client' you'll receive an error saying it's looking for
Missing required parameter for [Route: filament.admin.pages.helix] [URI: admin/{tenant}/helix] [Missing parameter: tenant].
Missing required parameter for [Route: filament.admin.pages.helix] [URI: admin/{tenant}/helix] [Missing parameter: tenant].
Which oddly, is the same thing that happened when I temporarily changed the path from 'admin' to 'app' To see one that is an eloquent model but I won't want affected by tenants - see 'Countries' for example. https://development.asmorphic.com/admin/1/countries
dormeljon
dormeljonβ€’11mo ago
Stuck with that issue as well. How to exclude non tenant related resource?
ConnorHowell
ConnorHowellβ€’11mo ago
In regards to the 'client' relationship issue; you'll want to override getEloquentQuery on your resources. My use case was I wanted a tenant (Partner) to have access to all records (Vehicle) for their users (Partner -> User -> Vehicle). e.g.
public static function getEloquentQuery(): Builder
{
$tenant = Filament::getTenant();
$users = $tenant->users()->pluck('user_id')->unique();
return Vehicle::whereIn('user_id', $users);
}
public static function getEloquentQuery(): Builder
{
$tenant = Filament::getTenant();
$users = $tenant->users()->pluck('user_id')->unique();
return Vehicle::whereIn('user_id', $users);
}
SirFat
SirFatβ€’11mo ago
yeah I think I saw that post - that expands the data to the wider dataset, but I'm at a loss if it's just a filament page of its own that doesn't care about tenancy. for the meantime I've just created a new panel 'app' and moved all the tenancy based items into it and kept the 'super admin' stuff in /admin/' - but the 'Register new client' on the '/app' front still gets: Missing required parameter for [Route: filament.app.pages.dashboard] [URI: app/{tenant}] [Missing parameter: tenant]. But that could be just adding whatever is needed to the newly created dashboard somehow (but the fact it's looking for app.pages.dashboard for what is now app.pages.app.app-dashboard may have something to do with it, but then I don't see a dashboard base either and the /admin one still works. Still doesn't completely address the problem, but it at least has the feeling of getting closer I would still prefer they all could exist happily together, so hopefully someone in the know sees this and takes an interest =] nope, that doesn't work because HasTenants is within the User object, so unless I want to seggregate Users too (I do not) I'm still affected by the same issue bump - it appears I'm not the only one chasing this one - there are a number of threads going at the moment and no real concrete solution. The "best" solution appears to be take the 'create another panel' approach. Is that really the best long term direction with this?
Solution
ModestasV
ModestasVβ€’11mo ago
For now, that's the only way to do this πŸ™‚ Other ways are hacky and does not fully work 100% of the time
SirFat
SirFatβ€’11mo ago
Cool. Well at least that's a direction, albeit not ideal, I know I'm not doing something silly when there is a more obvious solution - cheers!
ModestasV
ModestasVβ€’11mo ago
Yep, it's not ideal but for now - seems like the best
khairulazmi_
khairulazmi_β€’5mo ago
I am having trouble with this ... I have custom Edit Profile page, when go to /admin/new to create new tenant I got error [Missing parameter: tenant] . Im hoping to exclude EditProfile pages from tenant