Patient::count(), 'today_appointments' => Appointment::whereDate('appointment_date', $today)->count(), 'pending_invoices' => Invoice::where('status', 'sent')->orWhere('status', 'partial')->count(), 'month_revenue' => Invoice::whereMonth('invoice_date', $today->month) ->whereYear('invoice_date', $today->year) ->sum('paid_amount'), ]; $recent_appointments = Appointment::with('patient', 'user') ->whereDate('appointment_date', '>=', $today) ->orderBy('appointment_date') ->limit(5) ->get(); return view('dashboard', compact('stats', 'recent_appointments')); } }