@@ -5,33 +5,33 @@ |
||
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(\Illuminate\Support\Str::plural($name)) . 'Controller'; |
29 | 29 | $content = $this->getTemplate('controller') |
30 | - ->with([ |
|
31 | - 'name' => $controller, |
|
32 | - 'model' => $model |
|
33 | - ]) |
|
34 | - ->get(); |
|
30 | + ->with([ |
|
31 | + 'name' => $controller, |
|
32 | + 'model' => $model |
|
33 | + ]) |
|
34 | + ->get(); |
|
35 | 35 | |
36 | 36 | $this->save($content, "./app/Http/Controllers/{$controller}.php", "{$controller}"); |
37 | 37 | if(! $this->option('no-routes')){ |
@@ -75,7 +75,7 @@ |
||
75 | 75 | |
76 | 76 | protected function getResourceParams($modelName, $i) |
77 | 77 | { |
78 | - $i['name'] = Str::snake($modelName); |
|
78 | + $i['name'] = Str::snake($modelName); |
|
79 | 79 | |
80 | 80 | foreach(['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation){ |
81 | 81 | if(isset($i[$relation])){ |