Skip to content

Commit

Permalink
Added --all option to module:seed
Browse files Browse the repository at this point in the history
  • Loading branch information
Nil Késede committed Nov 4, 2015
1 parent 941f6c8 commit 0c5ca60
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions Commands/SeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down Expand Up @@ -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.'),
);
}
}
}

0 comments on commit 0c5ca60

Please sign in to comment.