@php $appName = App\Models\AppSetting::getValue('app_name', config('app.name', 'App')); $appLogo = App\Models\AppSetting::getValue('app_logo'); $branchUser = auth()->user(); $currentBranch = $branch ?? app(App\Services\BranchManagementService::class)->branchForUser($branchUser); $branchMembership = $currentBranch ? \App\Models\BranchUser::where('branch_id', $currentBranch->id)->where('user_id', $branchUser->id)->where('is_active', true)->first() : null; $branchCan = function (array $permissions) use ($branchUser, $branchMembership) { if (empty($permissions)) { return true; } foreach ($permissions as $permission) { try { if ($branchUser->can($permission)) { return true; } } catch (\Throwable) { continue; } } return $branchMembership && count(array_intersect($permissions, $branchMembership->permissions ?? [])) > 0; }; $items = [ ['route' => 'branch.dashboard', 'label' => 'Dashboard', 'icon' => 'fas fa-chart-line', 'permissions' => []], ['route' => 'branch.orders', 'label' => 'Orders', 'icon' => 'fas fa-box', 'permissions' => ['branch.orders.view', 'view_orders', 'manage_orders']], ['route' => 'branch.restaurants', 'label' => 'Stores', 'icon' => 'fas fa-store', 'permissions' => ['branch.restaurants.view', 'manage_restaurants']], ['route' => 'branch.drivers', 'label' => 'Drivers', 'icon' => 'fas fa-truck', 'permissions' => ['branch.drivers.view', 'manage_drivers']], ['route' => 'branch.zones', 'label' => 'Territories', 'icon' => 'fas fa-map-location-dot', 'permissions' => ['branch.zones.view', 'manage_zones']], ['route' => 'branch.wallet', 'label' => 'Wallet', 'icon' => 'fas fa-wallet', 'permissions' => ['branch.wallet.view', 'view_wallet', 'view_earnings']], ['route' => 'branch.settlements', 'label' => 'Settlements', 'icon' => 'fas fa-file-invoice-dollar', 'permissions' => ['branch.settlements.view', 'submit_settlement_requests', 'view_wallet']], ['route' => 'branch.reports', 'label' => 'Reports', 'icon' => 'fas fa-chart-pie', 'permissions' => ['branch.reports.view', 'view_reports']], ['route' => 'branch.settings', 'label' => 'Settings', 'icon' => 'fas fa-gear', 'permissions' => ['branch.settings.view', 'manage_staff']], ['route' => 'branch.tickets', 'label' => 'Support', 'icon' => 'fas fa-headset', 'permissions' => ['branch.tickets.view', 'manage_support_tickets', 'view_assigned_tasks']], ]; @endphp