@props([ 'routeName', 'iconPath', 'label', 'submenu' => [], 'routeParams' => [], 'dynamicRoutes' => [], 'permissionKey' => [], ]) @php $isActive = $routeName ? request()->routeIs($routeName) : false; if (!$isActive && count($submenu) > 0) { foreach ($submenu as $subitem) { if (request()->routeIs($subitem['route'])) { $isActive = true; break; } } } // Check if the current route matches any of the dynamic routes $isActive = $isActive || collect($dynamicRoutes)->contains(function ($route) { return request()->routeIs($route); }); // Check if the user has the necessary permissions $hasPermission = true; if (!empty($permissionKey)) { if (!auth()->user()->hasPermissionTo($permissionKey)) { $hasPermission = false; } } @endphp @if($hasPermission)
{{ $label }} {{-- @if(count($submenu) > 0) --}} {{-- @endif --}}
{{-- --}} {{----}} {{-- {{ $label }}--}} {{-- @if(count($submenu) > 0)--}} {{-- --}} {{-- @endif--}} {{--
--}} {{-- --}} @if(count($submenu) > 0) @endif