Loheide-eu-mitarbeiterplatt.../app/Http/Middleware/HandleInertiaRequests.php
Friederich Loheide 546c94db1c
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 4m47s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m40s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m0s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m51s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m1s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m45s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m36s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m21s
Profil zeigt geschriebene Beiträge, Als Person anmelden (0.27.1)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 10:03:27 +00:00

56 lines
2 KiB
PHP

<?php
namespace App\Http\Middleware;
use App\Push\WebPush;
use App\Support\Branding;
use App\Support\Impersonation;
use App\Support\Navigation;
use Illuminate\Http\Request;
use Inertia\Middleware;
class HandleInertiaRequests extends Middleware
{
protected $rootView = 'app';
public function __construct(
private readonly Branding $branding,
private readonly Navigation $navigation,
) {}
/**
* @return array<string, mixed>
*/
public function share(Request $request): array
{
$user = $request->user();
return [
...parent::share($request),
'branding' => $this->branding->toArray(),
'auth' => [
'user' => $user ? [
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
'initials' => $user->initials,
'job_title' => $user->job_title,
'avatar_url' => $user->avatarUrl(96),
'cover_url' => $user->coverUrl(),
'theme' => $user->theme,
'can_admin' => $user->canAccessAdmin(),
] : null,
],
'navigation' => fn () => $user ? $this->navigation->items($request, $user) : [],
'impersonation' => fn () => $user && app(Impersonation::class)->active() ? ['name' => $user->name, 'by' => app(Impersonation::class)->impersonator()?->name] : null,
'notifications' => fn () => $user ? ['unread' => $user->unreadNotifications()->count()] : null,
// Web-Push: öffentlicher Schlüssel für dieses Portal
'push' => fn () => $user && WebPush::supported() ? ['key' => app(WebPush::class)->publicKey()] : null,
'flash' => [
'status' => fn () => $request->session()->get('status'),
'comment' => fn () => $request->session()->get('comment'),
'form_submitted' => fn () => $request->session()->get('form_submitted'),
],
];
}
}