{{--
brafa Systems — admin sidebar.
Mirror of prototype/admin/shell.jsx → Sidebar component.
Hard constraints kept from the previous implementation:
• id="sidenav-main" — Material Dashboard's mobile toggle in
navs/auth.blade.php targets this id to slide the sidebar in.
• role_id == 1 gating on admin-only items.
• All href values use the existing named routes.
--}}
@php
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
$routeName = Route::currentRouteName();
$isSuperAdmin = Auth::check() && Auth::user()->role_id == 1;
/* Map current route → nav item id so we can flag the active item. */
$brafaActiveNav = match (true) {
in_array($routeName, ['dashboard']) => 'dashboard',
in_array($routeName, ['lock-overview']) => 'locks',
in_array($routeName, ['user-management']) => 'users',
in_array($routeName, ['lock-records']) => 'records',
in_array($routeName, ['staff.management']) => 'staff',
in_array($routeName, ['ajax.dashboard']) => 'ajax',
in_array($routeName, ['locks-by-month']) => 'stats',
in_array($routeName, ['rooms.index']) => 'rooms',
in_array($routeName, ['port.map']) => 'portmap',
in_array($routeName, ['notes-kanban']) => 'notes',
in_array($routeName, ['superadmin.parka-tokens']) => 'parka',
in_array($routeName, ['user-profile']) => 'profile',
in_array($routeName, ['set-api-key']) || str_starts_with((string) $routeName, 'properties.') => 'properties',
default => null,
};
/* If the user landed on one of the four MORE items, expand the group
on first paint so the active row isn't hidden under a collapsed header. */
$brafaMoreOpen = in_array($brafaActiveNav, ['ajax', 'portmap', 'notes', 'parka'], true);
$authUserName = Auth::check() ? Auth::user()->name : 'Guest';
$authUserPicture = Auth::check() && Auth::user()->picture
? asset('storage/' . Auth::user()->picture)
: null;
$authUserInitials = collect(explode(' ', trim((string) $authUserName)))
->filter()
->take(2)
->map(fn ($p) => strtoupper(mb_substr($p, 0, 1)))
->implode('');
$authUserRoleLabel = match (Auth::check() ? (int) Auth::user()->role_id : 0) {
1 => 'Superadmin',
2 => 'Admin',
default => 'Staff',
};
@endphp
@once
@push('js')
@endpush
@endonce