From ae2e04b38ef91f70ccc0ab9bb186f7ec496ca8ae Mon Sep 17 00:00:00 2001 From: Krishan Koenig Date: Wed, 28 Aug 2019 16:03:24 +0200 Subject: [PATCH] fix model with additional flag creation --- .../Database/MigrationMakeCommand.php | 20 ++++++++++--------- src/Commands/Foundation/ModelMakeCommand.php | 20 +++++++------------ .../Routing/ControllerMakeCommand.php | 16 +++++++-------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/Commands/Database/MigrationMakeCommand.php b/src/Commands/Database/MigrationMakeCommand.php index 82251cd..3e29312 100644 --- a/src/Commands/Database/MigrationMakeCommand.php +++ b/src/Commands/Database/MigrationMakeCommand.php @@ -31,10 +31,9 @@ class MigrationMakeCommand extends MakeMigration /** * Create a new migration install command instance. * - * @param Illuminate\Filesystem\Filesystem $creator - * @param \Illuminate\Database\Migrations\MigrationCreator $creator - * @param \Illuminate\Support\Composer $composer - * @return void + * @param Illuminate\Filesystem\Filesystem $creator + * @param \Illuminate\Database\Migrations\MigrationCreator $creator + * @param \Illuminate\Support\Composer $composer */ public function __construct(Filesystem $files, MigrationCreator $creator, Composer $composer) { @@ -50,15 +49,15 @@ public function __construct(Filesystem $files, MigrationCreator $creator, Compos */ protected function getMigrationPath() { - $path = $this->basePath().'database/migrations'; + $path = $this->basePath() . 'database/migrations'; if (! is_null($targetPath = $this->input->getOption('path'))) { $path = ! $this->usingRealPath() - ? $this->basePath().$targetPath + ? $this->basePath() . $targetPath : $targetPath; } - $this->makeDirectory($path.'/some_migration.php'); + $this->makeDirectory($path . '/some_migration.php'); return $path; } @@ -66,7 +65,8 @@ protected function getMigrationPath() /** * Build the directory for the class if necessary. * - * @param string $path + * @param string $path + * * @return string */ protected function makeDirectory($path) @@ -92,7 +92,9 @@ protected function additionalOptions() ['path', null, InputOption::VALUE_REQUIRED, 'The location where the migration file should be created'], - ['realpath', null, InputOption::VALUE_REQUIRED, 'Indicate any provided migration file paths are pre - resolved absolute paths'], + ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre - resolved absolute paths'], + + ['fullpath', null, InputOption::VALUE_NONE, 'Output the full path of the migration'], ]; } } diff --git a/src/Commands/Foundation/ModelMakeCommand.php b/src/Commands/Foundation/ModelMakeCommand.php index 90d65fb..dddaa5e 100644 --- a/src/Commands/Foundation/ModelMakeCommand.php +++ b/src/Commands/Foundation/ModelMakeCommand.php @@ -24,13 +24,11 @@ class ModelMakeCommand extends MakeModel */ protected function resolveDirectory() { - return $this->getDirInput().'src'; + return $this->getDirInput() . 'src'; } /** * Create a model factory for the model. - * - * @return void */ protected function createFactory() { @@ -39,15 +37,13 @@ protected function createFactory() $this->call('package:factory', [ 'name' => "{$factory}Factory", '--model' => $this->argument('name'), - '--namespace' => $this->rootNamespace(), - '--dir' => $this->basePath(), + '--namespace' => $this->getNamespaceInput(), + '--dir' => $this->getDirInput(), ]); } /** * Create a migration file for the model. - * - * @return void */ protected function createMigration() { @@ -56,15 +52,13 @@ protected function createMigration() $this->call('package:migration', [ 'name' => "create_{$table}_table", '--create' => $table, - '--namespace' => $this->rootNamespace(), - '--dir' => $this->basePath(), + '--namespace' => $this->getNamespaceInput(), + '--dir' => $this->getDirInput(), ]); } /** * Create a controller for the model. - * - * @return void */ protected function createController() { @@ -75,8 +69,8 @@ protected function createController() $this->call('package:controller', [ 'name' => "{$controller}Controller", '--model' => $this->option('resource') ? $modelName : null, - '--namespace' => $this->rootNamespace(), - '--dir' => $this->basePath(), + '--namespace' => $this->getNamespaceInput(), + '--dir' => $this->getDirInput(), ]); } } diff --git a/src/Commands/Routing/ControllerMakeCommand.php b/src/Commands/Routing/ControllerMakeCommand.php index f6fd0aa..3214691 100644 --- a/src/Commands/Routing/ControllerMakeCommand.php +++ b/src/Commands/Routing/ControllerMakeCommand.php @@ -24,9 +24,7 @@ class ControllerMakeCommand extends MakeController */ protected function resolveDirectory() { - // Illuminate\Routing\Controller DummyRootNamespaceHttp\Controllers\Controller; - - return $this->getDirInput().'src'; + return $this->getDirInput() . 'src'; } /** @@ -40,9 +38,9 @@ protected function buildClass($name) { $class = parent::buildClass($name); - if (str_contains($class, $this->rootNamespace().'Http\Controllers\Controller')) { + if (str_contains($class, $this->rootNamespace() . 'Http\Controllers\Controller')) { return str_replace( - $this->rootNamespace().'Http\Controllers\Controller', + $this->rootNamespace() . 'Http\Controllers\Controller', 'Illuminate\Routing\Controller', $class ); @@ -84,7 +82,8 @@ protected function buildParentReplacements() /** * Build the model replacement values. * - * @param array $replace + * @param array $replace + * * @return array */ protected function buildModelReplacements(array $replace) @@ -111,7 +110,8 @@ protected function buildModelReplacements(array $replace) /** * Get the fully-qualified model class name. * - * @param string $model + * @param string $model + * * @return string */ protected function parseModel($model) @@ -123,7 +123,7 @@ protected function parseModel($model) $model = trim(str_replace('/', '\\', $model), '\\'); if (! starts_with($model, $rootNamespace = $this->rootNamespace()) && ! starts_with($model, $this->laravel->getNamespace())) { - $model = $rootNamespace.'\\'.$model; + $model = $rootNamespace . '\\' . $model; } return $model;