Skip to content

Commit

Permalink
Merge branch 'master' into 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Gravitano committed Nov 6, 2015
2 parents 00c8d86 + bc232d7 commit 4c78c47
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 39 deletions.
16 changes: 10 additions & 6 deletions Commands/ControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/controller.stub', [
'MODULENAME' => $module->getStudlyName(),
'CONTROLLERNAME' => $this->getControllerName(),
'CLASS' => $this->getClass(),
'NAMESPACE' => $module->getLowername(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
'CLASS_NAMESPACE' => $this->getClassNamespace($module),
'MODULENAME' => $module->getStudlyName(),
'CONTROLLERNAME' => $this->getControllerName(),
'NAMESPACE' => $module->getLowername(),
'CLASS_NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getModuleName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
9 changes: 7 additions & 2 deletions Commands/GenerateFilterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/filter.stub', [
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'STUDLY_NAME' => $this->getFileName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
10 changes: 7 additions & 3 deletions Commands/GenerateProviderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/'.$stub.'.stub', [
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
12 changes: 9 additions & 3 deletions Commands/GenerateRouteProviderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ protected function getArguments()
*/
protected function getTemplateContents()
{
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/route-provider.stub', [
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
12 changes: 7 additions & 5 deletions Commands/MakeRequestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/request.stub', [
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getFileName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
2 changes: 1 addition & 1 deletion Commands/MigrateRollbackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function fire()
return;
}

foreach ($this->laravel['modules']->all() as $module) {
foreach (array_reverse($this->laravel['modules']->all()) as $module) {
$this->line('Running for module: <info>'.$module->getName().'</info>');

$this->rollback($module);
Expand Down
14 changes: 8 additions & 6 deletions Commands/ModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/model.stub', [
'MODULE' => $this->getModuleName(),
'NAME' => $this->getModelName(),
'FILLABLE' => $this->getFillable(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'NAME' => $this->getModelName(),
'FILLABLE' => $this->getFillable(),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
]))->render();
}

Expand Down
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.'),
);
}
}
}
1 change: 1 addition & 0 deletions Commands/SeedMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected function getTemplateContents()
'NAME' => $this->getSeederName(),
'MODULE' => $this->getModuleName(),
'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),

]))->render();
}

Expand Down
2 changes: 1 addition & 1 deletion Commands/stubs/scaffold/provider.stub
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class $CLASS$ extends ServiceProvider {
*/
public function boot()
{
$this->registerConfig();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
}

Expand Down
4 changes: 3 additions & 1 deletion ModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ protected function registerNamespaces()
{
$configPath = __DIR__.'/src/config/config.php';
$this->mergeConfigFrom($configPath, 'modules');
$this->publishes([$configPath => config_path('modules.php')]);
$this->publishes([
$configPath => config_path('modules.php')
], 'config');
}

/**
Expand Down

0 comments on commit 4c78c47

Please sign in to comment.