@extends('layouts.app') @section('title','Administração - GIGAX ARENA') @section('page_title','Administração') @php use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use App\Http\Controllers\Admin\SystemController; $currentUser = DB::table('users') ->select(['id','nickname','email','avatar_url','role']) ->where('id', session('user_id')) ->first(); $currentUserRole = strtolower((string) ($currentUser->role ?? session('user_role', 'user'))); $isAdmin = $currentUserRole === 'admin'; $isModerator = in_array($currentUserRole, ['admin','moderator'], true); $activeMatchesCount = Schema::hasTable('mix_training_matches') ? DB::table('mix_training_matches')->whereIn('status', ['in_progress','started','veto','waiting','ready_check'])->count() : 0; $historyCount = Schema::hasTable('mix_match_history') ? DB::table('mix_match_history')->count() : (Schema::hasTable('mix_training_history') ? DB::table('mix_training_history')->count() : 0); $adminLogsCount = Schema::hasTable('admin_action_logs') ? DB::table('admin_action_logs')->count() : 0; $playersOnline = Schema::hasColumn('users', 'is_online') ? DB::table('users')->where('is_online', 1)->count() : 0; $playersInQueue = Schema::hasTable('mix_queue_players') ? DB::table('mix_queue_players')->count() : 0; $playersInMatch = Schema::hasTable('mix_training_participants') ? DB::table('mix_training_participants')->whereNull('left_at')->distinct('user_id')->count('user_id') : 0; $matchesToday = Schema::hasTable('mix_training_matches') ? DB::table('mix_training_matches')->whereDate('created_at', today())->count() : 0; $krxValidationRequired = SystemController::isValidationEnabled(); // GIGAX AC ADMIN TOGGLE - fail-safe: se algo falhar, AC permanece obrigatório. $gxAcRequired = true; try { if (class_exists(\App\Services\GigaxAcValidationService::class)) { $gxAcRequired = (bool) (app(\App\Services\GigaxAcValidationService::class)->status()['required'] ?? true); } } catch (\Throwable $e) { $gxAcRequired = true; } $recentAdminLogs = Schema::hasTable('admin_action_logs') ? DB::table('admin_action_logs as l') ->leftJoin('users as u', 'u.id', '=', 'l.admin_id') ->select('l.*', 'u.nickname as admin_name') ->orderByDesc('l.created_at') ->limit(3) ->get() : collect(); $gxAcSummary = [ 'available' => false, 'online_count' => 0, 'players' => collect(), 'message' => null, ]; if (class_exists(\App\Services\GigaxAcPresenceService::class)) { try { $gxAcSummary = app(\App\Services\GigaxAcPresenceService::class)->summary(); } catch (\Throwable $e) { $gxAcSummary['message'] = 'Monitor do AC indisponível.'; } } $acOnlineCount = (int) ($gxAcSummary['online_count'] ?? 0); $acPlayers = collect($gxAcSummary['players'] ?? [])->take(5); @endphp @push('styles') @endpush @section('content')