resolver = $resolver;
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$previousConnection = $this->resolver->getDefaultConnection();
$this->resolver->setDefaultConnection($this->getDatabase());
collect([
Modulo::class,
Funcionalidade::class,
FuncionalidadeSub::class,
Menu::class,
Permissao::class,
])->each(function ($model) {
$this->getOutput()->writeln("Seeding: {$model}");
$startTime = microtime(true);
$model::run();
$runTime = number_format((microtime(true) - $startTime) * 1000, 2);
$this->getOutput()->writeln("Seeded: {$model} ({$runTime}ms)");
});
if ($previousConnection) {
$this->resolver->setDefaultConnection($previousConnection);
}
$this->info('Permissions seeding completed successfully.');
return 0;
}
/**
* Get the name of the database connection to use.
*
* @return string
*/
protected function getDatabase()
{
$database = $this->input->getOption('database');
return $database ?: $this->laravel['config']['database.default'];
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed'],
];
}
}