Skip to content

Commit

Permalink
Merge pull request #222 from briba/master
Browse files Browse the repository at this point in the history
Fixes #189
  • Loading branch information
gravitano committed Nov 6, 2015
2 parents 941f6c8 + 58df48a commit bc232d7
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 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();
$name = $this->argument('module');

if ($module) {
if ($this->module->has($module)) {
$this->dbseed($module);

return $this->info("Module [$module] seeded.");
if ($name) {
if (!$this->module->has($name)) {
return $this->error("Module [$name] does not exists.");
}

return $this->error("Module [$module] does not exists.");
$class = $this->getSeederName($name);
if (class_exists($class)) {
$this->dbseed($name);

return $this->info("Module [$name] seeded.");
} else {
return $this->error("Class [$class] does not exists.");
}
}

foreach ($this->module->all() as $name) {
$this->dbseed($name);
foreach ($this->module->getOrdered() as $module) {
$name = $module->getName();

if (class_exists($this->getSeederName($name))) {
$this->dbseed($name);

$this->info("Module [$name] seeded.");
}
}

return $this->info('All modules seeded.');
Expand Down Expand Up @@ -87,7 +98,7 @@ public function getSeederName($name)

$namespace = $this->laravel['modules']->config('namespace');

return $namespace.'\\'.$name.'\Database\Seeders\\'.$name.'DatabaseSeeder';
return $namespace.'\\'.$name.'\Database\Seeders\\'.$name.'TableSeeder';
}

/**
Expand All @@ -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 bc232d7

Please sign in to comment.