Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m47s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m41s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m8s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m6s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m25s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m23s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m40s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m8s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
51 lines
1.6 KiB
PHP
51 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),
|
|
'cover_url' => $user->coverUrl(),
|
|
'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'),
|
|
],
|
|
];
|
|
}
|
|
}
|