@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')
👥
Players online{{ $playersOnline }}usuários no site
⌁
Em partida{{ $activeMatchesCount }}{{ $playersInMatch }} jogadores
🏆
Partidas hoje{{ $matchesToday }}criadas hoje
⚠
Logs{{ $adminLogsCount }}registros administrativos
▣
AC Online{{ $acOnlineCount }}heartbeats ativos
↗
Histórico{{ $historyCount }}partidas finalizadas
Anti-Cheat Online Atualização automática • 5s
@forelse($acPlayers as $player)
{{ $player->nickname }}{{ $player->process_name ?: 'AC ativo' }}
@empty
Nenhum AC onlineaguardando heartbeat
@endforelse

Partidas em andamento

{{ $activeMatchesCount }}
@csrf
{{ $krxValidationRequired ? 'Validação ativa' : 'Validação desativada' }}
Carregando partidas...

Alertas recentes

{{ $recentAdminLogs->count() }}
@forelse($recentAdminLogs as $log)
REGISTRO
{{ $log->action_type ?? 'Ação administrativa' }}{{ $log->admin_name ?? 'Sistema' }} • {{ \Illuminate\Support\Carbon::parse($log->created_at)->format('d/m/Y H:i') }}
@empty
INFO
Nenhum alerta recenteO sistema está sem ocorrências.
@endforelse

Jogadores

Online{{ $playersOnline }}
Em fila{{ $playersInQueue }}
Em partida{{ $playersInMatch }}

Estatísticas gerais

Partidas hoje{{ $matchesToday }}
Histórico{{ $historyCount }}
Logs registrados{{ $adminLogsCount }}

Sistema

Banco SQLOnline
Anti-Cheat{{ $acOnlineCount }} online
AC obrigatório{{ $gxAcRequired ? 'ON' : 'OFF / TESTE' }}
Validação{{ $krxValidationRequired ? 'Ativa' : 'Livre' }}
@endsection @push('scripts') @endpush {{-- GIGAX_ADMIN_HASH_NAV --}} @push('scripts') @endpush