@@ -6,10 +6,10 @@ |
||
| 6 | 6 | |
| 7 | 7 | class PublishCommand extends Command { |
| 8 | 8 | |
| 9 | - protected $signature = 'wn:publish |
|
| 9 | + protected $signature = 'wn:publish |
|
| 10 | 10 | {--f : force the publishing.} |
| 11 | 11 | '; |
| 12 | - protected $description = 'Publishes the laravel-generators config file to the config folder of your project'; |
|
| 12 | + protected $description = 'Publishes the laravel-generators config file to the config folder of your project'; |
|
| 13 | 13 | protected $fs; |
| 14 | 14 | |
| 15 | 15 | public function __construct(Filesystem $fs) |
@@ -5,34 +5,34 @@ |
||
| 5 | 5 | |
| 6 | 6 | class ControllerCommand extends BaseCommand { |
| 7 | 7 | |
| 8 | - protected $signature = 'wn:controller |
|
| 8 | + protected $signature = 'wn:controller |
|
| 9 | 9 | {model : Name of the model (with namespace if not App)} |
| 10 | 10 | {--no-routes= : without routes} |
| 11 | 11 | {--force= : override the existing files} |
| 12 | 12 | {--laravel : Use Laravel style route definitions} |
| 13 | 13 | '; |
| 14 | 14 | |
| 15 | - protected $description = 'Generates RESTful controller using the RESTActions trait'; |
|
| 15 | + protected $description = 'Generates RESTful controller using the RESTActions trait'; |
|
| 16 | 16 | |
| 17 | 17 | public function handle() |
| 18 | 18 | { |
| 19 | - $model = $this->argument('model'); |
|
| 20 | - $name = ''; |
|
| 21 | - if(strrpos($model, "\\") === false){ |
|
| 22 | - $name = $model; |
|
| 23 | - $model = "App\\" . $model; |
|
| 24 | - } else { |
|
| 25 | - $name = explode("\\", $model); |
|
| 26 | - $name = $name[count($name) - 1]; |
|
| 27 | - } |
|
| 19 | + $model = $this->argument('model'); |
|
| 20 | + $name = ''; |
|
| 21 | + if(strrpos($model, "\\") === false){ |
|
| 22 | + $name = $model; |
|
| 23 | + $model = "App\\" . $model; |
|
| 24 | + } else { |
|
| 25 | + $name = explode("\\", $model); |
|
| 26 | + $name = $name[count($name) - 1]; |
|
| 27 | + } |
|
| 28 | 28 | $controller = ucwords(str_plural($name)) . 'Controller'; |
| 29 | 29 | $content = $this->getTemplate('controller') |
| 30 | - ->with([ |
|
| 31 | - 'name' => $controller, |
|
| 32 | - 'model' => $model, |
|
| 30 | + ->with([ |
|
| 31 | + 'name' => $controller, |
|
| 32 | + 'model' => $model, |
|
| 33 | 33 | 'model_name' => $name |
| 34 | - ]) |
|
| 35 | - ->get(); |
|
| 34 | + ]) |
|
| 35 | + ->get(); |
|
| 36 | 36 | |
| 37 | 37 | $this->save($content, "./app/Http/Controllers/{$controller}.php", "{$controller}"); |
| 38 | 38 | if(! $this->option('no-routes')){ |
@@ -7,28 +7,28 @@ |
||
| 7 | 7 | |
| 8 | 8 | class TemplateLoader { |
| 9 | 9 | |
| 10 | - protected $fs; |
|
| 10 | + protected $fs; |
|
| 11 | 11 | |
| 12 | - protected $loaded; |
|
| 12 | + protected $loaded; |
|
| 13 | 13 | |
| 14 | - public function __construct(Filesystem $fs) |
|
| 15 | - { |
|
| 16 | - $this->fs = $fs; |
|
| 17 | - $this->loaded = []; |
|
| 18 | - } |
|
| 14 | + public function __construct(Filesystem $fs) |
|
| 15 | + { |
|
| 16 | + $this->fs = $fs; |
|
| 17 | + $this->loaded = []; |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public function load($name) |
|
| 21 | - { |
|
| 22 | - if(! isset($this->loaded[$name])){ |
|
| 23 | - $path = config("lumen-generators.custom_templates.{$name}", __DIR__ . "/../../templates/{$name}.wnt"); |
|
| 20 | + public function load($name) |
|
| 21 | + { |
|
| 22 | + if(! isset($this->loaded[$name])){ |
|
| 23 | + $path = config("lumen-generators.custom_templates.{$name}", __DIR__ . "/../../templates/{$name}.wnt"); |
|
| 24 | 24 | |
| 25 | - try { |
|
| 26 | - $this->loaded[$name] = $this->fs->get($path); |
|
| 27 | - } catch(\Exception $e) { |
|
| 28 | - throw new TemplateException("Unable to read the file '{$path}'"); |
|
| 29 | - } |
|
| 30 | - } |
|
| 31 | - return new Template($this, $this->loaded[$name]); |
|
| 32 | - } |
|
| 25 | + try { |
|
| 26 | + $this->loaded[$name] = $this->fs->get($path); |
|
| 27 | + } catch(\Exception $e) { |
|
| 28 | + throw new TemplateException("Unable to read the file '{$path}'"); |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | + return new Template($this, $this->loaded[$name]); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | } |