@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' => 'Daily Routes', 'icon' => 'route', 'route' => 'daily-routes.index', 'active' => 'daily-routes.*'], ['label' => 'Visits', 'icon' => 'pin', 'route' => 'visits.index', 'active' => 'visits.*'], ['label' => 'Daily Reports', 'icon' => 'report', 'route' => 'daily-reports.index', 'active' => 'daily-reports.*'], ['label' => 'Customer Orders', 'icon' => 'orders', 'route' => 'orders.index', 'active' => 'orders.*'], ['label' => 'Returns', 'icon' => 'returns', 'route' => 'returns.index', 'active' => 'returns.*'], ['label' => 'Customer Applications', 'icon' => 'check', 'route' => 'customers.applications', 'active' => 'customers.applications'], ['label' => 'Customers', 'icon' => 'customers', 'route' => 'customers.index', 'active' => 'customers.index,customers.create,customers.store,customers.show,customers.edit,customers.update,customers.import*'], ['label' => 'Salesmen / Vans', 'icon' => 'team', 'route' => 'salesmen.index', 'active' => 'salesmen.*'], ['label' => 'Fleet Management', 'icon' => 'truck', 'route' => 'vehicles.index', 'active' => 'vehicles.*'], ['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.*'], ], 'Warehouse Operations' => [ ['label' => 'Warehouse Workspace', 'icon' => 'box', 'route' => 'warehouse-operations.index', 'active' => 'warehouse-operations.*'], ['label' => 'Stock Requests', 'icon' => 'orders', 'route' => 'stock-requests.index', 'active' => 'stock-requests.*', 'status' => null], ['label' => 'Stock Receipts', 'icon' => 'check', 'route' => 'stock-receipts.index', 'active' => 'stock-receipts.*'], ['label' => 'RMA Handovers', 'icon' => 'returns', 'route' => 'return-handovers.index', 'active' => 'return-handovers.*'], ['label' => 'Warehouse Preparation', 'icon' => 'box', 'route' => 'stock-requests.index', 'active' => 'stock-requests.index', 'status' => 'approved'], ['label' => 'Awaiting Release', 'icon' => 'check', 'route' => 'stock-requests.index', 'active' => 'stock-requests.index', 'status' => 'awaiting_admin_release'], ['label' => 'Receiving Issues', 'icon' => 'report', 'route' => 'stock-requests.index', 'active' => 'stock-requests.index', 'status' => 'closed_with_variance'], ['label' => 'QA Dataset', 'icon' => 'tools', 'route' => 'qa-dataset.index', 'active' => 'qa-dataset.*'], ], '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.*'], ['label' => 'Developer Docs', 'icon' => 'report', 'route' => 'project-docs.index', 'active' => 'project-docs.*'], ], ]; $navGroupsSalesman = [ 'My Work' => [ ['label' => 'Dashboard', 'icon' => 'grid', 'route' => 'dashboard', 'active' => 'dashboard'], ['label' => 'My Daily Route', 'icon' => 'route', 'route' => 'daily-routes.index', 'active' => 'daily-routes.*'], ['label' => 'My Visits', 'icon' => 'pin', 'route' => 'visits.index', 'active' => 'visits.*'], ['label' => 'My Daily Reports', 'icon' => 'report', 'route' => 'daily-reports.index', 'active' => 'daily-reports.*'], ['label' => 'My Orders', 'icon' => 'orders', 'route' => 'orders.index', 'active' => 'orders.*'], ['label' => 'My Returns', 'icon' => 'returns', 'route' => 'returns.index', 'active' => 'returns.*'], ['label' => 'My RMA Handovers', 'icon' => 'returns', 'route' => 'return-handovers.index', 'active' => 'return-handovers.*'], ['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.*'], ], ]; $navGroupsSupervisor = [ 'Operations' => [ ['label' => 'Dashboard', 'icon' => 'grid', 'route' => 'dashboard', 'active' => 'dashboard'], ['label' => 'Daily Routes', 'icon' => 'route', 'route' => 'daily-routes.index', 'active' => 'daily-routes.*'], ['label' => 'Visits', 'icon' => 'pin', 'route' => 'visits.index', 'active' => 'visits.*'], ['label' => 'Daily Reports', 'icon' => 'report', 'route' => 'daily-reports.index', 'active' => 'daily-reports.*'], ['label' => 'Customer Orders', 'icon' => 'orders', 'route' => 'orders.index', 'active' => 'orders.*'], ['label' => 'Customers', 'icon' => 'customers', 'route' => 'customers.index', 'active' => 'customers.*'], ['label' => 'Returns', 'icon' => 'returns', 'route' => 'returns.index', 'active' => 'returns.*'], ['label' => 'RMA Handovers', 'icon' => 'returns', 'route' => 'return-handovers.index', 'active' => 'return-handovers.*'], ['label' => 'Stock Requests', 'icon' => 'orders', 'route' => 'stock-requests.index', 'active' => 'stock-requests.*', 'status' => null], ['label' => 'Stock Receipts', 'icon' => 'check', 'route' => 'stock-receipts.index', 'active' => 'stock-receipts.*'], ['label' => 'Warehouse Preparation', 'icon' => 'box', 'route' => 'stock-requests.index', 'active' => 'stock-requests.index', 'status' => 'approved'], ['label' => 'Awaiting Release', 'icon' => 'check', 'route' => 'stock-requests.index', 'active' => 'stock-requests.index', 'status' => 'awaiting_admin_release'], ['label' => 'Receiving Issues', 'icon' => 'report', 'route' => 'stock-requests.index', 'active' => 'stock-requests.index', 'status' => 'closed_with_variance'], ], 'Field Tools' => [ ['label' => 'Inventory Check', 'icon' => 'check', 'route' => 'salesman.inventory-check', 'active' => 'salesman.inventory-check*'], ['label' => 'Van Stock', 'icon' => 'truck', 'route' => 'van-stocks.index', 'active' => 'van-stocks.*'], ['label' => 'Van Boxes', 'icon' => 'box', 'route' => 'van-boxes.index', 'active' => 'van-boxes.*'], ['label' => 'Catalogs', 'icon' => 'catalog', 'route' => 'catalogs.index', 'active' => 'catalogs.*'], ], ]; $navGroups = $user->isAdmin() ? $navGroupsAdmin : ($user->isSupervisor() ? $navGroupsSupervisor : $navGroupsSalesman); $currentPage = collect($navGroups)->flatten(1)->first(function ($item) { $routeMatches = collect(explode(',', $item['active']))->contains(fn ($pattern) => request()->routeIs(trim($pattern))); return $routeMatches && (!array_key_exists('status', $item) || request('status') === $item['status']); }); @endphp