authorizeAp('ap.view'); $businessId = $this->businessId(); $stats = [ 'resources' => CapacityResource::forBusiness($businessId)->where('is_active', true)->count(), 'schedule_runs' => ScheduleRun::forBusiness($businessId)->where('status', 'completed')->count(), 'sop_cycles' => SopCycle::forBusiness($businessId)->count(), 'latest_run' => ScheduleRun::forBusiness($businessId)->latest('id')->first(), 'latest_sop' => SopCycle::forBusiness($businessId)->latest('cycle_month')->first(), ]; $integrations = [ 'industrial_engineering' => $this->bridge->isIndustrialEngineeringAvailable(), 'shop_floor' => $this->bridge->isShopFloorAvailable(), 'maintenance' => $this->bridge->isMaintenanceAvailable(), ]; return view('advancedplanning::dashboard.index', compact('stats', 'integrations')); } }