File manager - Edit - /var/www/html/portalHomolog/app/Console/Commands/RollbackImportAtasCommand.php
Back
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; class RollbackImportAtasCommand extends Command { protected $signature = 'atas:rollback-import {--force : Executa sem pedir confirmacao}'; protected $description = 'Remove todos os dados importados da tabela atas.'; public function handle(): int { if ( !$this->option('force') && !$this->confirm('ATENCAO: todos os registros da tabela atas serao APAGADOS. Deseja continuar?') ) { $this->info('Rollback cancelado.'); return self::SUCCESS; } try { $atasCount = DB::table('atas')->count(); DB::statement('SET FOREIGN_KEY_CHECKS=0'); DB::table('atas')->truncate(); DB::statement('SET FOREIGN_KEY_CHECKS=1'); $this->info("Tabela atas limpa ({$atasCount} registros removidos)."); $this->newLine(); $this->info('Rollback concluido com sucesso!'); return self::SUCCESS; } catch (\Throwable $e) { DB::statement('SET FOREIGN_KEY_CHECKS=1'); $this->error('Rollback falhou: ' . $e->getMessage()); return self::FAILURE; } } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings