Skip to content

Commit

Permalink
Merge pull request #252 from nejtr0n/patch-1
Browse files Browse the repository at this point in the history
Generate seeders in right namespace
  • Loading branch information
kaidesu authored Oct 20, 2016
2 parents c80cc86 + 895fa92 commit 007d86a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Console/Commands/ModuleSeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ protected function seed($slug)
$module = $this->module->where('slug', $slug);
$params = [];
$namespacePath = $this->module->getNamespace();
$rootSeeder = $module['namespace'].'DatabaseSeeder';
$fullPath = $namespacePath.'\\'.$module['namespace'].'\Database\Seeds\\'.$rootSeeder;
$rootSeeder = $module['name'].'DatabaseSeeder';
$fullPath = $namespacePath.'\\'.$module['name'].'\Database\Seeds\\'.$rootSeeder;

if (class_exists($fullPath)) {
if ($this->option('class')) {
Expand Down
11 changes: 11 additions & 0 deletions src/Console/Generators/MakeSeederCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,15 @@ protected function parseName($name)
{
return $name;
}

/**
* Replace namespace in seeder stub
*
* @param string $name
* @return string
*/
protected function getNamespace($name)
{
return module_class($this->argument('slug'), 'Database\Seeds');
}
}
2 changes: 2 additions & 0 deletions src/Console/Generators/stubs/seeder.stub
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace DummyNamespace;

use Illuminate\Database\Seeder;

class DummyClass extends Seeder
Expand Down

0 comments on commit 007d86a

Please sign in to comment.