Spatie multitenancy, resolve resource page to tenant specific class
In my resource:
I'd like to switch that If this proves too difficult to figure out or fix, I might use a generic
I've tried this approach, but it got very messy indeed. So I'm still looking for a solution or workaround.
BredaVO
part for the current tenant.
The current tenant is determined with this:
https://spatie.be/docs/laravel-multitenancy/v3/basic-usage/automatically-determining-the-current-tenant
But... Filament getPages()
runs before Multitenancy DomainTenantFinder
, so at this point I don't have access to the current tenant yet.
RequestWorkflow
class, and redirect certain method calls to a tenant specific class. But there are methods specifically created for a tenant, so I'd need some __call()
magic to redirect those. I'm afraid it will get quite messy.15 Replies
I guess the problem is that Filaments
getPages()
runs when Laravel is building routes, and Spatie determines the current tenant in Middleware. I wouldn't know how to work around this.
bump Anyone please?Pages are LW components therefore you can set a middleware via properties I think.
No need to customize this during registration
I don't understand. I want the 'edit' page to be dynamic.
getPages
is parsed for routes, before middleware.I have never worked with spatie multitenancy and I don't really understand how that docs page related to the issue. Why do you need to make changes to the route registration if the tenant is identified in a middleware?
As a far as I see you need to add a
tenant
middleware to your edit page. That's it
Each tenant has its own edit page. So I'm too late for page middleware.
So what's the difference?
Different form schema?
Between the edit pages? They have a complex workflow with multiple "steps" (forms).
Also custom actions.
Shouldn't something like this work on the Edit page?
The step forms are already in saparate tenant specific files. But actions to proceed to next step, return to previous, and other custom actions with custom conditions are in the tenant specific edit page.
I tried that approach. Actions were the next challenge, because I think I'd have to redirect them to the tenant specific method using __call() ? Does that even work with LW?
I tried that approach.So that works for the form?
because I think I'd have to redirect them to the tenant specific method using __call()I don't understand what you are trying to do. What tenant specific methods to you have? Do you have an example?
The "Only proceed ..." part is tenant specific.
Which users are notified for which step is tenant specific.
Then maybe extract that code to an action (the action pattern, not Filament Action)?
GetNotifiablesForTenant
etcI guess I could do that. I just thought it would be more flexible to do whatever I want or need per tenant. I'll give it some thought. Thanks for your help.
You still do whatever you want or need per tenant. You just do it somewhere else.
I guess so. I'll have to refactor some actions, but it will be cleaner in the end.