user(); return $user instanceof User ? $user : null; } public function panel(Panel $panel): Panel { return $panel ->default() ->id('admin') ->path('admin') ->login() ->profile(isSimple: false) // Two-factor login with an authenticator app (TOTP) and recovery codes; mandatory for every account. ->multiFactorAuthentication( [AppAuthentication::make()->brandName('FeWo Stommer')->recoverable()], isRequired: true, ) ->userMenuItems([ 'admin-mode' => Action::make('switchAdminMode') ->label(fn (): string => (self::currentUser()?->adminMode() ?? AdminMode::Expert)->other()->switchLabel()) ->icon(fn (): Heroicon => self::currentUser()?->adminMode() === AdminMode::Simple ? Heroicon::OutlinedAdjustmentsHorizontal : Heroicon::OutlinedSparkles) ->action(function () { $user = self::currentUser(); $user?->forceFill(['admin_mode' => $user->adminMode()->other()])->save(); return redirect(url()->previous()); }), ]) ->brandName('FeWo Stommer ยท Verwaltung') ->navigationGroups(['Vermietung', 'Webseite', 'System']) ->colors([ 'primary' => Color::Sky, ]) ->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources') ->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages') ->pages([ Dashboard::class, ]) ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets') ->widgets([ AccountWidget::class, ]) ->middleware([ EncryptCookies::class, AddQueuedCookiesToResponse::class, StartSession::class, AuthenticateSession::class, ShareErrorsFromSession::class, PreventRequestForgery::class, SubstituteBindings::class, DisableBladeIconComponents::class, DispatchServingFilamentEvent::class, ]) ->authMiddleware([ Authenticate::class, ]); } }