@props([ 'menu', 'active' => null, 'subActive' => null, 'level' => 0, ]) @php $hasChildren = $menu->children->count(); $isExternal = str_contains($menu->target_url, 'http'); $url = $hasChildren ? '#' : ($isExternal ? $menu->target_url : url($menu->target_url . $menu->target_slug . ($menu->action ?? ''))); $submenuId = 'submenu-' . md5($menu->caption . $level); $currentPath = request()->path(); // contoh: "/", "profile-bkd", dll $isHome = $currentPath === '/' || $currentPath === ''; $isMenuHome = !$hasChildren && ( ($menu->target_url === '/' || $menu->target_url === '') && ($menu->target_slug === '' || $menu->target_slug === null) ); $isActive = $active === $menu->caption || ($isHome && $isMenuHome); $isSubActive = ($subActive ?? '') === $menu->caption; @endphp