user()->can('manage-portal')) { return Inertia::render('dashboard', ['summary' => null]); } $counts = InterestRequest::query()->selectRaw('status, count(*) as total') ->groupBy('status')->pluck('total', 'status'); return Inertia::render('dashboard', ['summary' => [ 'requestsByStatus' => collect(['received', 'in_review', 'contacted', 'closed']) ->mapWithKeys(fn ($status) => [$status => (int) ($counts[$status] ?? 0)]), 'publishedOpportunities' => Opportunity::published()->count(), 'draftOpportunities' => Opportunity::where('status', 'draft')->count(), 'activeSectors' => Sector::where('is_active', true)->count(), 'recentRequests' => InterestRequest::orderByDesc('id')->limit(5) ->get(['id', 'reference', 'sector_interest', 'status', 'created_at']), ]]); } }