savannabits / filament-modules

Integration of Filament with nWidart/laravel-modules: Create independent Filament Files for each Laravel Module
https://filamentphp.com/plugins/coolsam-modules
MIT License
109 stars 22 forks source link

Multiple contexts with multiple guards not working #12

Closed lukas-frey closed 1 year ago

lukas-frey commented 1 year ago

I have two modules, each with it's own filament context. Each of these contexts have it's own guard.

Whenever you create a context, this package adds the context's service provider to config/app.php into the providers array.

However Laravel seems to load all of those service providers and they override each other. Depending on the order of those service providers, it will use the guard of the last in order service provider for ALL contexts.

So in this case:

'providers' => [
    ...
    Modules\Client\Providers\FilamentServiceProvider::class,
    Modules\Admin\Providers\FilamentServiceProvider::class,
    ...
]

The Admin Module's filament context's guard is used in ALL guards.

In this case:

'providers' => [
    ...
    Modules\Admin\Providers\FilamentServiceProvider::class,
    Modules\Client\Providers\FilamentServiceProvider::class,
    ...
]

The Client Module's filament context's guard is used in ALL guards.

lukas-frey commented 1 year ago

I was looking at the wrong place for the error, it does work and doesn't matter in which order they are. But in any case, any custom guard results in the error described in #13