@php
use App\Services\NavigationMenuService;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Auth;
use Filament\Facades\Filament;
// Try to get user first for debugging
$user = null;
try {
$user = Filament::auth()->user();
} catch (\Exception $e) {
$user = Auth::user();
}
// Let NavigationMenuService handle user retrieval - it will try both Filament and standard Auth
// This ensures consistent behavior and proper fallback handling
$menu = NavigationMenuService::getMenu($user);
// Debug: Log what menu we got (temporary - remove in production)
if ($user) {
$menuKeys = array_keys($menu);
$totalChildren = 0;
foreach ($menu as $group => $data) {
if (isset($data['children'])) {
$totalChildren += count($data['children']);
}
}
Log::info('=== SIDEBAR RENDERING === User: ' . $user->email . ' (ID: ' . $user->id . ') | Menu groups: ' . count($menu) . ' (' . implode(', ', $menuKeys) . ') | Total children: ' . $totalChildren);
} else {
Log::warning('=== SIDEBAR RENDERING === NO USER! Menu has ' . count($menu) . ' groups: ' . implode(', ', array_keys($menu)));
}
// Get full path - isActive() will normalize it
$currentPath = request()->path();
@endphp