- Fix: Notifiable-Trait zum User-Model hinzugefuegt (behebt notify()-500er) - Installer: SMTP-Verbindungstest mit EsmtpTransport + Ueberspringen-Link - Admin: Neuer E-Mail-Tab mit SMTP-Konfiguration + Verbindungstest - Admin: Lazy Quill-Initialisierung (nur sichtbare Locale wird geladen) - Uebersetzungen: 17 neue Mail-Keys in allen 6 Sprachen Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
82 lines
2.7 KiB
PHP
Executable File
82 lines
2.7 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Enums\EventStatus;
|
|
use App\Enums\ParticipantStatus;
|
|
use App\Enums\UserRole;
|
|
use App\Models\ActivityLog;
|
|
use App\Models\Event;
|
|
use App\Models\Invitation;
|
|
use App\Models\Player;
|
|
use App\Models\User;
|
|
use App\Services\SupportApiService;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\View\View;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index(): View
|
|
{
|
|
$stats = [
|
|
'users' => 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'
|
|
));
|
|
}
|
|
}
|