@php $companySettings = \App\Models\CompanySetting::current(); $user = auth()->user(); $navGroupsAdmin = [ 'Overview' => [ ['label' => 'Dashboard', 'icon' => 'grid', 'route' => 'dashboard', 'active' => 'dashboard'], ['label' => 'Notifications', 'icon' => 'bell', 'route' => 'admin.notifications.index', 'active' => 'admin.notifications.*'], ['label' => 'Routes & Visits', 'icon' => 'route', 'route' => 'admin.routes.index', 'active' => 'admin.routes.*'], ['label' => 'Catalog Center', 'icon' => 'catalog', 'route' => 'catalog-center.index', 'active' => 'catalog-center.*'], ['label' => 'Import Center', 'icon' => 'import', 'route' => 'import-center.index', 'active' => 'import-center.*'], ], 'Catalogs' => [ ['label' => 'Catalogs', 'icon' => 'catalog', 'route' => 'catalogs.index', 'active' => 'catalogs.*'], ['label' => 'Price Lists', 'icon' => 'money', 'route' => 'price-imports.index', 'active' => 'price-imports.*'], ['label' => 'Shipments', 'icon' => 'box', 'route' => 'shipments.index', 'active' => 'shipments.*'], ['label' => 'Products', 'icon' => 'product', 'route' => 'products.index', 'active' => 'products.*'], ['label' => 'SOH Library', 'icon' => 'image', 'route' => 'soh.index', 'active' => 'soh.*'], ], 'Sales Team' => [ ['label' => 'Customer Orders', 'icon' => 'orders', 'route' => 'orders.index', 'active' => 'orders.*'], ['label' => 'Customers', 'icon' => 'customers', 'route' => 'customers.index', 'active' => 'customers.*'], ['label' => 'Salesmen / Vans', 'icon' => 'team', 'route' => 'salesmen.index', 'active' => 'salesmen.*'], ['label' => 'Fleet Management', 'icon' => 'truck', 'route' => 'vehicles.index', 'active' => 'vehicles.*'], ['label' => 'Assign Van Inventory', 'icon' => 'upload', 'route' => 'van-stocks.admin-upload', 'active' => 'van-stocks.admin-upload'], ['label' => 'Van Stock Imports', 'icon' => 'truck', 'route' => 'van-stocks.index', 'active' => 'van-stocks.index,van-stocks.show,van-stocks.create,van-stocks.generate-catalog'], ['label' => 'Van Box Management', 'icon' => 'box', 'route' => 'van-boxes.index', 'active' => 'van-boxes.*'], ['label' => 'Inventory Reports', 'icon' => 'report', 'route' => 'inventory-checks.index', 'active' => 'inventory-checks.*'], ], 'Locations' => [ ['label' => 'Areas', 'icon' => 'pin', 'route' => 'areas.index', 'active' => 'areas.*'], ], 'Settings' => [ ['label' => 'Company Settings', 'icon' => 'settings', 'route' => 'company-settings.edit', 'active' => 'company-settings.*'], ['label' => 'System Tools', 'icon' => 'tools', 'route' => 'system-tools.index', 'active' => 'system-tools.*'], ], ]; $navGroupsSalesman = [ 'My Work' => [ ['label' => 'Dashboard', 'icon' => 'grid', 'route' => 'dashboard', 'active' => 'dashboard'], ['label' => 'My Orders', 'icon' => 'orders', 'route' => 'orders.index', 'active' => 'orders.*'], ['label' => 'My Customers', 'icon' => 'customers', 'route' => 'customers.index', 'active' => 'customers.*'], ['label' => 'My Inventory Check', 'icon' => 'check', 'route' => 'salesman.inventory-check', 'active' => 'salesman.inventory-check*'], ['label' => 'My Van Stock', 'icon' => 'truck', 'route' => 'van-stocks.index', 'active' => 'van-stocks.*'], ['label' => 'My Van Boxes', 'icon' => 'box', 'route' => 'van-boxes.index', 'active' => 'van-boxes.*'], ['label' => 'My Catalogs', 'icon' => 'catalog', 'route' => 'catalogs.index', 'active' => 'catalogs.*'], ], ]; $navGroups = $user->isAdmin() ? $navGroupsAdmin : $navGroupsSalesman; $currentPage = collect($navGroups)->flatten(1)->first(function ($item) { return collect(explode(',', $item['active']))->contains(fn ($pattern) => request()->routeIs(trim($pattern))); }); @endphp