{{-- Admin header right-side controls. The admin layout renders this once and a small inline script moves it into every page's [data-admin-header-right] slot. Same control set as the user dashboard header so admin gets theme toggle, notifications, account menu, and a quick "Back to app" shortcut without each admin view having to inline them. --}} @php $au = auth()->user(); $base = $au ? ($au->name ?: $au->email) : ''; $parts = preg_split('/\s+/', trim((string) $base)); $initials = $au ? strtoupper(substr($parts[0] ?? '', 0, 1) . substr($parts[1] ?? '', 0, 1)) : 'WA'; // Role label shown under the user's name in the avatar button. // Tries Spatie roles first (Super Admin / Admin) and falls back to // the legacy users.role string — never blank, never hardcoded. $roleLabel = 'Member'; if ($au) { try { if (method_exists($au, 'getRoleNames')) { $names = $au->getRoleNames(); if ($names && $names->count()) { $roleLabel = (string) $names->first(); } } } catch (\Throwable $e) { } if ($roleLabel === 'Member' && !empty($au->role)) { $roleLabel = ucwords(str_replace(['_', '-'], ' ', (string) $au->role)); } } // Lightweight platform-health probe powering the "All systems normal" // pill. DB ping + queue freshness — no remote calls, no slow checks. // Status: 'ok' | 'warn' | 'down'. $sysStatus = 'ok'; $sysLabel = __('All systems normal'); try { \DB::connection()->getPdo(); } catch (\Throwable $e) { $sysStatus = 'down'; $sysLabel = __('Database unreachable'); } if ($sysStatus === 'ok') { try { $stuck = \DB::table('jobs') ->where('reserved_at', '<', now()->subMinutes(10)->timestamp) ->count(); if ($stuck > 0) { $sysStatus = 'warn'; $sysLabel = $stuck . ' ' . __('stuck jobs'); } } catch (\Throwable $e) { /* no jobs table — fine */ } } $sysDot = $sysStatus === 'ok' ? 'bg-wa-green' : ($sysStatus === 'warn' ? 'bg-accent-amber' : 'bg-accent-coral'); @endphp