@php // Items store a plain path slug in `url` or `route` (not a registered // Laravel route name), so build hrefs the same way the rest of the site // does rather than using MenuItem::link(). $sidebarMenuHref = function ($item) { $path = $item->url ?: $item->route; return $path ? url(rtrim($path, '/') . '/') : '#'; }; $currentUrl = url()->current(); @endphp @foreach ($items as $item) @php $hasChildren = $item->children->count() > 0; $itemUrl = $sidebarMenuHref($item); $isActive = ($currentUrl === $itemUrl); @endphp @if ($hasChildren) @else @endif @endforeach