When working on multiple-role systems, separating the Resources per role is often a good idea. For this, Filament comes with out-of-the-box support for multiple panels. This allows us to create different designs and colored interfaces for clear indication.
We have the Auth
Panel, which is only responsible for log-in and registration. The path for this panel is set to root, and pages, resources, and widgets auto-discovery are removed.
app/Providers/Filament/AuthPanelProvider.php:
use App\Filament\Pages\Auth\Register; class AuthPanelProvider extends PanelProvider{ public function panel(Panel $panel): Panel { return $panel ->default() ->id('auth') ->path('') ->login() ->registration(Register::class) ->colors([ 'primary' => Color::Amber, ]) ->middleware([ EncryptCookies::class, AddQueuedCookiesToResponse::class, StartSession::class, AuthenticateSession::class, ShareErrorsFromSession::class, VerifyCsrfToken::class, SubstituteBindings::class, DisableBladeIconComponents::class, DispatchServingFilamentEvent::class, ]); }}
After logging in or registering to redirect the user to the correct resource and panel, the response is created and added to the AppServiceProvider
as a singleton.
app/Http/Responses/LoginResponse.php:
use Illuminate\Http\RedirectResponse;use Livewire\Features\SupportRedirects\Redirector;use Filament\Http\Responses\Auth\LoginResponse as BaseLogin; class LoginResponse extends BaseLogin{ // ...
We also have an example of how to do this using a Single Panel