FilamentF
Filament3y ago
John

Spatie multitenancy, resolve resource page to tenant specific class

In my resource:

use App\Filament\Resources\RequestResource\Pages\CreateRequest;
use App\Filament\Resources\RequestResource\Pages\ListRequests;

class RequestResource extends App\Filament\BaseResource
{
    // [...]

    public static function getPages(): array
    {
        return [
            'index' => ListRequests::route('/'),
            'create' => CreateRequest::route('/create'),
            // TODO Bind current tenant dynamically
            'edit' => \App\Classes\Tenant\BredaVo\RequestWorkflow::route('/{record}/edit'),
        ];
    }
}


I'd like to switch that 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.

If this proves too difficult to figure out or fix, I might use a generic 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.
I've tried this approach, but it got very messy indeed. So I'm still looking for a solution or workaround.
Was this page helpful?