Contract::count(), 'active' => Contract::active()->count(), 'expiring_soon' => Contract::expiringSoon(30)->count(), 'expired' => Contract::where('status', 'expired')->count(), 'by_type' => Contract::select('type', \DB::raw('count(*) as count'))->groupBy('type')->get()->keyBy('type'), ]; // Recent logs $recentLogs = AuditLog::with('user')->latest()->take(10)->get(); // Upcoming Contracts (Timeline) $upcomingContracts = Contract::whereNotNull('end_date') ->whereDate('end_date', '>=', now()) ->orderBy('end_date', 'asc') ->take(6) ->get(); // Dashboard Note $dashboardNote = GlobalSetting::get('dashboard_note'); // External Links $links = Link::active()->get(); return view('dashboard', compact('contractStats', 'recentLogs', 'upcomingContracts', 'dashboardNote', 'links')); } /** * Update the dashboard note. */ public function updateNote(Request $request) { GlobalSetting::set('dashboard_note', $request->input('note')); return back()->with('success', 'Pense-bête mis à jour.'); } }