From 0c5ca60d89fe9dc0154cfcca954a3d22a5e9ab43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nil=20K=C3=A9sede?= Date: Wed, 4 Nov 2015 01:34:30 -0300 Subject: [PATCH] Added --all option to module:seed --- Commands/SeedCommand.php | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Commands/SeedCommand.php b/Commands/SeedCommand.php index a2f1168..0c9e787 100644 --- a/Commands/SeedCommand.php +++ b/Commands/SeedCommand.php @@ -35,20 +35,31 @@ public function fire() { $this->module = $this->laravel['modules']; - $module = Str::studly($this->argument('module')) ?: $this->getModuleName(); + if ($this->argument('module')) { + $modules = $this->argument('module'); + } + elseif ($this->option('all')) { + $modules = $this->module->all(); + } + else { + try { + $modules = $this->getModuleName(); + } catch (\Exception $e) { + return $this->info("Use module:use to select which module you want to migrate."); + } + } - if ($module) { - if ($this->module->has($module)) { - $this->dbseed($module); + foreach ((array) $modules as $module) { + $name = $module instanceof Module ? Str::studly($module->getName()) : Str::studly($module); - return $this->info("Module [$module] seeded."); + if (! $this->module->has($name)) { + $this->error("Module [$module] does not exists."); + continue; } - return $this->error("Module [$module] does not exists."); - } - - foreach ($this->module->all() as $name) { $this->dbseed($name); + + $this->info("Module [$module] seeded."); } return $this->info('All modules seeded.'); @@ -111,7 +122,8 @@ protected function getOptions() { return array( array('class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder', null), + array('all', null, InputOption::VALUE_NONE, 'Whether or not we should seed all modules.'), array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed.'), ); } -} +} \ No newline at end of file