/** * Execute the console command. * * @return void */ public function fire() { $table = null; $all = $this->option('all'); if ($all) { $tables = DB::getDoctrineSchemaManager()->listTableNames(); $table = implode(',', $tables); } else { $table = $this->argument('table'); } if (is_null($table)) { return $this->error('Provide table name or --all parameter'); } $tables = explode(',', $table); foreach ($tables as $table) { Controller::lock(trim($table)); $this->getOutput()->writeln("Table <info>{$table}</info> was locked"); } }
/** * Run seed */ protected function run() { $this->setForeignKeyChecks(0); $seeder = $this->getSeeder(); $table = $seeder->getTable(); if (Controller::isLocked($table)) { Controller::restore($table); $this->writeOutput('<info>Locked:</info> ' . $seeder->getTitle()); } else { if ($this->isTruncate()) { $seeder->truncate(); } $this->fill($seeder); $this->writeOutput('<info>Seeded:</info> ' . $seeder->getTitle()); } $this->setForeignKeyChecks(1); }