From 56f0d9c0a9827edf5953bf8f9a1cfddf5eeb6e0d Mon Sep 17 00:00:00 2001 From: Josiah Dahl Date: Mon, 7 Aug 2017 11:51:53 -0700 Subject: [PATCH] Ensure commands work and tests pass --- src/Commands/ControllerCommand.php | 7 +++++-- src/Commands/ResourceCommand.php | 6 ++++-- src/Commands/ResourcesCommand.php | 6 ++++-- src/Commands/RouteCommand.php | 5 ++--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Commands/ControllerCommand.php b/src/Commands/ControllerCommand.php index bd39d4a..96449fc 100644 --- a/src/Commands/ControllerCommand.php +++ b/src/Commands/ControllerCommand.php @@ -9,7 +9,7 @@ class ControllerCommand extends BaseCommand { {model : Name of the model (with namespace if not App)} {--no-routes= : without routes} {--force= : override the existing files} - {--laravel= : Boolean (default false) Use Laravel style route definitions} + {--laravel : Use Laravel style route definitions} '; protected $description = 'Generates RESTful controller using the RESTActions trait'; @@ -38,9 +38,12 @@ class ControllerCommand extends BaseCommand { $options = [ 'resource' => snake_case($name, '-'), '--controller' => $controller, - '--laravel' => $this->input->hasOption('laravel') ? $this->option('laravel') : false ]; + if ($this->option('laravel')) { + $options['--laravel'] = true; + } + $this->call('wn:route', $options); } } diff --git a/src/Commands/ResourceCommand.php b/src/Commands/ResourceCommand.php index 804e18f..8d27183 100644 --- a/src/Commands/ResourceCommand.php +++ b/src/Commands/ResourceCommand.php @@ -17,7 +17,7 @@ class ResourceCommand extends BaseCommand { {--path=app : where to store the model file.} {--parsed : tells the command that arguments have been already parsed. To use when calling the command from an other command and passing the parsed arguments and options} {--force= : override the existing files} - {--laravel= : Boolean (default false) Use Laravel style route definitions} + {--laravel : Use Laravel style route definitions} '; protected $description = 'Generates a model, migration, controller and routes for RESTful resource'; @@ -69,8 +69,10 @@ class ResourceCommand extends BaseCommand { 'model' => $modelName, '--force' => $this->option('force'), '--no-routes' => false, - '--laravel' => $this->input->hasOption('laravel') ? $this->option('laravel') : false ]; + if ($this->option('laravel')) { + $controllerOptions['--laravel'] = true; + } $this->call('wn:controller', $controllerOptions); // generating model factory diff --git a/src/Commands/ResourcesCommand.php b/src/Commands/ResourcesCommand.php index 54641ec..666f4f5 100644 --- a/src/Commands/ResourcesCommand.php +++ b/src/Commands/ResourcesCommand.php @@ -10,7 +10,7 @@ class ResourcesCommand extends BaseCommand { {file : Path to the file containing resources declarations} {--path=app : where to store the model files.} {--force= : override the existing files} - {--laravel= : Boolean (default false) Use Laravel style route definitions} + {--laravel= : Use Laravel style route definitions} '; @@ -36,8 +36,10 @@ class ResourcesCommand extends BaseCommand { '--belongs-to-many' => $i['belongsToMany'], '--path' => $this->option('path'), '--force' => $this->option('force'), - '--laravel' => $this->input->hasOption('laravel') ? $this->option('laravel') : false ]; + if ($this->option('laravel')) { + $options['--laravel'] = true; + } $this->call('wn:resource', $options); } diff --git a/src/Commands/RouteCommand.php b/src/Commands/RouteCommand.php index f199560..eda1918 100644 --- a/src/Commands/RouteCommand.php +++ b/src/Commands/RouteCommand.php @@ -8,7 +8,7 @@ class RouteCommand extends BaseCommand { protected $signature = 'wn:route {resource : Name of the resource.} {--controller= : Name of the RESTful controller.} - {--laravel= : Boolean (default false) Use Laravel style route definitions} + {--laravel :R Use Laravel style route definitions} '; protected $description = 'Generates RESTful routes.'; @@ -16,7 +16,7 @@ class RouteCommand extends BaseCommand { public function handle() { $resource = $this->argument('resource'); - $laravelRoutes = $this->input->hasOption('laravel') ? $this->option('laravel') : false; + $laravelRoutes = $this->option('laravel'); $templateFile = 'routes'; $routesPath = 'routes/web.php'; if ($laravelRoutes) { @@ -61,7 +61,6 @@ class RouteCommand extends BaseCommand { 'controller' => $this->getController() ]) ->get(); - $this->save($content, $routesPath, "{$resource} routes", true); }