error('Tabela users não encontrada.'); return self::FAILURE; } foreach (['is_premium', 'is_gx'] as $column) { if (!Schema::hasColumn('users', $column)) { $this->error("Campo users.{$column} não existe."); $this->line('Execute primeiro o SQL de instalação ou use o install.php deste pacote.'); return self::FAILURE; } } $identifier = trim((string) $this->argument('usuario')); $plan = strtolower(trim((string) $this->argument('plano'))); if (!in_array($plan, ['premium', 'gx', 'comum', 'status'], true)) { $this->error('Plano inválido. Use: premium, gx, comum ou status.'); return self::INVALID; } $query = DB::table('users'); if (ctype_digit($identifier)) { $query->where('id', (int) $identifier); } else { $query->where('email', $identifier); } $user = $query->first(); if (!$user) { $this->error("Usuário não encontrado: {$identifier}"); return self::FAILURE; } $premium = (bool) ($user->is_premium ?? false); $gx = (bool) ($user->is_gx ?? false); $current = $gx ? 'GX' : ($premium ? 'PREMIUM' : 'COMUM'); $this->newLine(); $this->info('GIGAX ARENA • PLANO ADMINISTRATIVO'); $this->line('ID: #' . $user->id); if (isset($user->name) && $user->name) $this->line('Nome: ' . $user->name); if (isset($user->email) && $user->email) $this->line('E-mail: ' . $user->email); $this->line('Plano atual: ' . $current); if ($plan === 'status') { $this->line('Premium: ' . ($premium ? 'SIM' : 'NÃO')); $this->line('GX: ' . ($gx ? 'SIM' : 'NÃO')); $this->line('Pode criar sala: ' . (($premium || $gx) ? 'SIM' : 'NÃO')); $this->newLine(); return self::SUCCESS; } $values = match ($plan) { 'premium' => ['is_premium' => 1, 'is_gx' => 0], 'gx' => ['is_premium' => 0, 'is_gx' => 1], 'comum' => ['is_premium' => 0, 'is_gx' => 0], }; DB::table('users')->where('id', $user->id)->update($values); $newPlan = strtoupper($plan); $this->line('Novo plano: ' . $newPlan); $this->newLine(); $this->info("✓ {$newPlan} aplicado com sucesso."); $this->info('✓ Permissão de criação de sala: ' . ($plan === 'comum' ? 'BLOQUEADA' : 'LIBERADA')); $this->newLine(); return self::SUCCESS; } }