User::count(), 'players' => Player::count(), 'upcoming_events' => Event::where('status', EventStatus::Published) ->where('start_at', '>=', now())->count(), 'open_invitations' => Invitation::whereNull('accepted_at') ->where('expires_at', '>', now())->count(), ]; // Events mit vielen offenen Rückmeldungen $eventsWithOpenResponses = Event::with('team') ->where('status', EventStatus::Published) ->where('start_at', '>=', now()) ->withCount(['participants as open_count' => function ($q) { $q->where('status', ParticipantStatus::Unknown); }]) ->orderByDesc('open_count') ->limit(10) ->get() ->filter(fn ($e) => $e->open_count > 0) ->take(5); // DSGVO: User mit hochgeladenem Dokument, aber ohne Admin-Bestätigung $pendingDsgvoUsers = User::where('role', UserRole::User) ->whereNotNull('dsgvo_consent_file') ->whereNull('dsgvo_accepted_at') ->orderBy('name') ->get(); // Letzte 10 DSGVO-Ereignisse $dsgvoEvents = ActivityLog::with('user') ->whereIn('action', [ 'dsgvo_consent_uploaded', 'dsgvo_consent_confirmed', 'dsgvo_consent_revoked', 'dsgvo_consent_removed', 'dsgvo_consent_rejected', 'account_self_deleted', 'child_auto_deactivated', ]) ->latest('created_at') ->limit(10) ->get(); // Update-Check (cached 24h, nur wenn registriert) $supportService = app(SupportApiService::class); if ($supportService->isRegistered()) { $supportService->checkForUpdate(); } $hasUpdate = $supportService->hasUpdate(); $updateVersion = $hasUpdate ? (Cache::get('support.update_check')['latest_version'] ?? null) : null; return view('admin.dashboard', compact( 'stats', 'eventsWithOpenResponses', 'pendingDsgvoUsers', 'dsgvoEvents', 'hasUpdate', 'updateVersion' )); } }