Oben im Seitenmenue waehlt man die Wohnung; Listen, neue Eintraege, Belegungsplan und Preise & Angebote folgen ihr. Ein geoeffneter Eintrag einer anderen Wohnung schaltet auf diese um. Galerie und Ersatz-Titelbild der Website zeigen nur Fotos der Wohnung des Bausteins und Fotos ohne Wohnung. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
108 lines
4.6 KiB
PHP
108 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Providers\Filament;
|
|
|
|
use App\Enums\AdminMode;
|
|
use App\Http\Controllers\SwitchPropertyController;
|
|
use App\Http\Middleware\ResolveTheme;
|
|
use App\Models\User;
|
|
use Filament\Actions\Action;
|
|
use Filament\Auth\MultiFactor\App\AppAuthentication;
|
|
use Filament\Facades\Filament;
|
|
use Filament\Http\Middleware\Authenticate;
|
|
use Filament\Http\Middleware\AuthenticateSession;
|
|
use Filament\Http\Middleware\DisableBladeIconComponents;
|
|
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
|
use Filament\Pages\Dashboard;
|
|
use Filament\Panel;
|
|
use Filament\PanelProvider;
|
|
use Filament\Support\Colors\Color;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Filament\View\PanelsRenderHook;
|
|
use Filament\Widgets\AccountWidget;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
|
use Illuminate\Cookie\Middleware\EncryptCookies;
|
|
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
|
|
use Illuminate\Routing\Middleware\SubstituteBindings;
|
|
use Illuminate\Session\Middleware\StartSession;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
|
|
|
class AdminPanelProvider extends PanelProvider
|
|
{
|
|
private static function currentUser(): ?User
|
|
{
|
|
$user = Filament::auth()->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');
|
|
})
|
|
->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,
|
|
ResolveTheme::class,
|
|
AuthenticateSession::class,
|
|
ShareErrorsFromSession::class,
|
|
PreventRequestForgery::class,
|
|
SubstituteBindings::class,
|
|
DisableBladeIconComponents::class,
|
|
DispatchServingFilamentEvent::class,
|
|
])
|
|
->authMiddleware([
|
|
Authenticate::class,
|
|
]);
|
|
}
|
|
}
|