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([ 'tenant-switch' => Action::make('switchTenant') ->label('Anderer Mandant') ->icon(Heroicon::OutlinedArrowsRightLeft) ->visible(fn (): bool => self::currentUser()?->showsTenantSwitch() ?? false) ->url(fn (): ?string => self::currentUser()?->otherTenantAdminUrl()), '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') // As long as the site is not switched live, every page shows where the e-mails go. ->renderHook(PanelsRenderHook::BODY_START, fn (): View => view('filament.test-mode-banner')) // Apartment switcher at the top of the menu; lists and new records follow the chosen apartment. ->renderHook(PanelsRenderHook::SIDEBAR_NAV_START, fn (): View => view('filament.property-switcher')) ->authenticatedRoutes(function (): void { Route::post('wohnung-wechseln', SwitchPropertyController::class)->name('switch-property'); Route::get('vorgaenge/{booking}/dokument-vorschau/{kind}', DocumentPreviewController::class)->name('document-preview'); }) ->navigationGroups(['Verwaltung', 'Einrichtung', '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, ResolveTheme::class, AuthenticateSession::class, ShareErrorsFromSession::class, PreventRequestForgery::class, SubstituteBindings::class, DisableBladeIconComponents::class, DispatchServingFilamentEvent::class, ]) ->authMiddleware([ Authenticate::class, ]); } }