adds roles

This commit is contained in:
2026-02-16 11:19:06 +01:00
parent ebaeb1722d
commit 4dc64c22cb
29 changed files with 495 additions and 89 deletions

View File

@@ -6,7 +6,9 @@
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Gate;
use Inertia\Middleware;
use Laravel\Nova\Nova;
final class HandleInertiaRequests extends Middleware
{
@@ -32,6 +34,7 @@ public function share(Request $request): array
...parent::share($request),
'auth' => [
'user' => $this->getAuthenticatedUser(),
'logo_href' => $this->getLogoHref(),
],
'flash' => [
'success' => fn () => Arr::get($request->session()->all(), 'success'),
@@ -57,4 +60,18 @@ private function getAuthenticatedUser(): ?array
'email' => $user->email,
];
}
/**
* Determine logo href based on user Nova access.
*/
private function getLogoHref(): string
{
$user = auth()->user();
if ($user !== null && Gate::allows('viewNova', $user)) {
return Nova::path();
}
return '/';
}
}