First Commit

This commit is contained in:
marco
2026-09-01 10:46:29 -03:00
commit bf96b77e9c
10000 changed files with 3508600 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace App\Console\Commands;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Illuminate\Database\Capsule\Manager as Capsule;
use Symfony\Component\Console\Helper\Table;
class DbListCommand extends Command
{
protected static $defaultName = 'db:list';
protected static $defaultDescription = 'Lista todas as tabelas do banco de dados';
protected function execute(InputInterface $input, OutputInterface $output): int
{
$connection = Capsule::connection();
$dbName = $connection->getDatabaseName();
$output->writeln("<info>Tabelas no banco de dados: {$dbName}</info>");
$tables = $connection->select('SHOW TABLES');
$key = "Tables_in_{$dbName}";
if (empty($tables)) {
$output->writeln('<info>Nenhuma tabela encontrada no banco de dados.</info>');
return Command::SUCCESS;
}
$table = new Table($output);
$table->setHeaders(['Tabela', 'Total de Registros']);
foreach ($tables as $t) {
$tableName = $t->$key;
$count = $connection->table($tableName)->count();
$table->addRow([$tableName, $count]);
}
$table->render();
$output->writeln("<info>Total de tabelas: " . count($tables) . "</info>");
return Command::SUCCESS;
}
}