Loheide-eu-mitarbeiterplatt.../app/Http/Middleware/HandleInertiaRequests.php
Friederich Loheide 9320d602a8
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 4m42s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m33s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m48s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 8m0s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 8m6s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m10s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m19s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m21s
Kommentare mit Antworten unter Neuigkeiten
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 20:13:41 +00:00

50 lines
1.6 KiB
PHP

<?php
namespace App\Http\Middleware;
use App\Support\Branding;
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),
'theme' => $user->theme,
'can_admin' => $user->canAccessAdmin(),
] : null,
],
'navigation' => fn () => $user ? $this->navigation->items($request, $user) : [],
'notifications' => fn () => $user ? ['unread' => $user->unreadNotifications()->count()] : null,
'flash' => [
'status' => fn () => $request->session()->get('status'),
'comment' => fn () => $request->session()->get('comment'),
'form_submitted' => fn () => $request->session()->get('form_submitted'),
],
];
}
}