analyticsService = $analyticsService; } public function index() { try { $todayRevenue = $this->analyticsService->getTodayRevenue(); $profitData = $this->analyticsService->getProfitData('today'); $customerAnalytics = $this->analyticsService->getCustomerAnalytics(); $orderStats = $this->analyticsService->getOrderStats(); } catch (\Exception $e) { // Fallback values if service fails $todayRevenue = ['current' => 0, 'previous' => 0, 'percentage_change' => 0, 'trend' => 'up']; $profitData = ['profit_margin' => 0, 'percentage_change' => 0, 'trend' => 'up']; $customerAnalytics = ['total_customers' => 0, 'active_today' => 0]; $orderStats = ['current' => 0, 'previous' => 0, 'percentage_change' => 0, 'trend' => 'up']; } return view('dashboard', compact( 'todayRevenue', 'profitData', 'customerAnalytics', 'orderStats' )); } }