From f6dc01f2261655dceff4dd6ea7768cede5f7838d Mon Sep 17 00:00:00 2001 From: Syahril Zulkefli Date: Mon, 17 Aug 2015 18:39:22 +0800 Subject: [PATCH 1/7] Added publishing group tag for config file Added publishing file group tag for config file so we can use php artisan vendor:publish --tag=config --- ModulesServiceProvider.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ModulesServiceProvider.php b/ModulesServiceProvider.php index 0763b82..592f8e0 100644 --- a/ModulesServiceProvider.php +++ b/ModulesServiceProvider.php @@ -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'); } /** From 4b74850d6fc5eeab644d54ff273d32a87c0356ac Mon Sep 17 00:00:00 2001 From: Marcus Reinhardt Date: Thu, 20 Aug 2015 16:44:21 +0200 Subject: [PATCH 2/7] fixed missing stub replacements --- Commands/ControllerCommand.php | 16 ++++++++++------ Commands/GenerateFilterCommand.php | 9 +++++++-- Commands/GenerateProviderCommand.php | 10 +++++++--- Commands/GenerateRouteProviderCommand.php | 12 +++++++++--- Commands/MakeRequestCommand.php | 12 +++++++----- Commands/ModelCommand.php | 14 ++++++++------ Commands/SeedMakeCommand.php | 1 + 7 files changed, 49 insertions(+), 25 deletions(-) diff --git a/Commands/ControllerCommand.php b/Commands/ControllerCommand.php index 1b958f8..6e2b0c5 100644 --- a/Commands/ControllerCommand.php +++ b/Commands/ControllerCommand.php @@ -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(); } diff --git a/Commands/GenerateFilterCommand.php b/Commands/GenerateFilterCommand.php index 0239e51..bc2c990 100644 --- a/Commands/GenerateFilterCommand.php +++ b/Commands/GenerateFilterCommand.php @@ -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(); } diff --git a/Commands/GenerateProviderCommand.php b/Commands/GenerateProviderCommand.php index f1fb2d8..976df64 100644 --- a/Commands/GenerateProviderCommand.php +++ b/Commands/GenerateProviderCommand.php @@ -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(); } diff --git a/Commands/GenerateRouteProviderCommand.php b/Commands/GenerateRouteProviderCommand.php index 43c47b6..04bc1ba 100644 --- a/Commands/GenerateRouteProviderCommand.php +++ b/Commands/GenerateRouteProviderCommand.php @@ -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(); } diff --git a/Commands/MakeRequestCommand.php b/Commands/MakeRequestCommand.php index 4da7609..82bec02 100644 --- a/Commands/MakeRequestCommand.php +++ b/Commands/MakeRequestCommand.php @@ -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(); } diff --git a/Commands/ModelCommand.php b/Commands/ModelCommand.php index 81ed01d..0a9cf14 100644 --- a/Commands/ModelCommand.php +++ b/Commands/ModelCommand.php @@ -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(); } diff --git a/Commands/SeedMakeCommand.php b/Commands/SeedMakeCommand.php index 83414ae..88bc825 100644 --- a/Commands/SeedMakeCommand.php +++ b/Commands/SeedMakeCommand.php @@ -65,6 +65,7 @@ protected function getTemplateContents() 'NAME' => $this->getSeederName(), 'MODULE' => $this->getModuleName(), 'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'), + ]))->render(); } From a90f915e48d3742fda7e89914a9934874809b528 Mon Sep 17 00:00:00 2001 From: vagrant Date: Fri, 23 Oct 2015 10:15:59 +0000 Subject: [PATCH 3/7] fix command module:migrate-rollback to run modules in reverse order --- Commands/MigrateRollbackCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/MigrateRollbackCommand.php b/Commands/MigrateRollbackCommand.php index 07a7208..f26bf7e 100644 --- a/Commands/MigrateRollbackCommand.php +++ b/Commands/MigrateRollbackCommand.php @@ -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: '.$module->getName().''); $this->rollback($module); From e990804bb903ba4c04196e3eafe50b599ffbbe6a Mon Sep 17 00:00:00 2001 From: Kallef Alexandre de Souza Date: Tue, 27 Oct 2015 13:10:01 -0200 Subject: [PATCH 4/7] Order boot provider, supports the lang module Ordering boot provider, now config module supports the languages module. --- Commands/stubs/scaffold/provider.stub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/stubs/scaffold/provider.stub b/Commands/stubs/scaffold/provider.stub index 83f845a..e040038 100644 --- a/Commands/stubs/scaffold/provider.stub +++ b/Commands/stubs/scaffold/provider.stub @@ -18,8 +18,8 @@ class $CLASS$ extends ServiceProvider { */ public function boot() { - $this->registerConfig(); $this->registerTranslations(); + $this->registerConfig(); $this->registerViews(); } 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 5/7] 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 From 0cd498649a79246d93b0b1c4ec5654a3508b2608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nil=20K=C3=A9sede?= Date: Wed, 4 Nov 2015 01:51:07 -0300 Subject: [PATCH 6/7] Fix the module without seed class issue --- Commands/SeedCommand.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Commands/SeedCommand.php b/Commands/SeedCommand.php index 0c9e787..66722b7 100644 --- a/Commands/SeedCommand.php +++ b/Commands/SeedCommand.php @@ -57,9 +57,11 @@ public function fire() continue; } - $this->dbseed($name); + if (class_exists($this->getSeederName($name))) { + $this->dbseed($name); - $this->info("Module [$module] seeded."); + $this->info("Module [$module] seeded."); + } } return $this->info('All modules seeded.'); @@ -98,7 +100,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'; } /** From 58df48a19ec637565907176f66a6eda1bff8d2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nil=20K=C3=A9sede?= Date: Wed, 4 Nov 2015 02:15:04 -0300 Subject: [PATCH 7/7] Remove -all option and remove user module option --- Commands/SeedCommand.php | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/Commands/SeedCommand.php b/Commands/SeedCommand.php index 66722b7..2c6edd6 100644 --- a/Commands/SeedCommand.php +++ b/Commands/SeedCommand.php @@ -35,32 +35,30 @@ public function fire() { $this->module = $this->laravel['modules']; - 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."); + $name = $this->argument('module'); + + if ($name) { + if (!$this->module->has($name)) { + return $this->error("Module [$name] does not exists."); } - } - foreach ((array) $modules as $module) { - $name = $module instanceof Module ? Str::studly($module->getName()) : Str::studly($module); + $class = $this->getSeederName($name); + if (class_exists($class)) { + $this->dbseed($name); - if (! $this->module->has($name)) { - $this->error("Module [$module] does not exists."); - continue; + return $this->info("Module [$name] seeded."); + } else { + return $this->error("Class [$class] does not exists."); } + } + + foreach ($this->module->getOrdered() as $module) { + $name = $module->getName(); if (class_exists($this->getSeederName($name))) { $this->dbseed($name); - $this->info("Module [$module] seeded."); + $this->info("Module [$name] seeded."); } }