New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PROPOSAL] Generate seeds for all tables with one command #129
Comments
Currently we can use: class ISeedAllCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'iseed:all';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Make seeders for all tables by iseed';
/**
* @var Connection
*/
protected $connection;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
$this->connection = DB::getDoctrineConnection();
}
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$tableNames = $this->getShortestTableNames();
$tableNames = array_diff($tableNames, ['migrations']);
Artisan::call('iseed', [
'tables' => implode(',', $tableNames),
// '--force' => true,
]);
}
protected function getShortestTableNames(): array
{
$sm = $this->connection->getSchemaManager();
$databaseName = $this->connection->getDatabase();
$fullSchema = $sm->createSchema();
$tableNames = $fullSchema->getTableNames();
$shortTableNames = str_replace("$databaseName.", '', $tableNames);
return $shortTableNames;
}
} |
Closing. More info: #58 (comment) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#24
Example of implementation:
Or
The text was updated successfully, but these errors were encountered: