@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | class ModelCommand extends BaseCommand { |
5 | 5 | |
6 | - protected $signature = 'wn:model |
|
6 | + protected $signature = 'wn:model |
|
7 | 7 | {name : Name of the model.} |
8 | 8 | {--fillable= : the fillable fields.} |
9 | 9 | {--dates= : date fields.} |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | {--force= : override the existing files} |
25 | 25 | '; |
26 | 26 | |
27 | - protected $description = 'Generates a model class for a RESTfull resource'; |
|
27 | + protected $description = 'Generates a model class for a RESTfull resource'; |
|
28 | 28 | |
29 | 29 | public function handle() |
30 | 30 | { |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | protected function getAsArrayFields($arg, $isOption = true) |
51 | 51 | { |
52 | - $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); |
|
52 | + $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); |
|
53 | 53 | if(is_string($arg)){ |
54 | - $arg = explode(',', $arg); |
|
54 | + $arg = explode(',', $arg); |
|
55 | 55 | } else if(! is_array($arg)) { |
56 | 56 | $arg = []; |
57 | 57 | } |
@@ -93,32 +93,32 @@ discard block |
||
93 | 93 | $template = $this->getTemplate($template); |
94 | 94 | foreach ($items as $item) { |
95 | 95 | $item['type'] = $type; |
96 | - if ($parser == 'relations') { |
|
97 | - $item['model'] = $this->prependNamespace($item['model'] ?: $item['name']); |
|
98 | - } else if ($parser != 'relations') { |
|
99 | - switch($type) { |
|
100 | - case "hasManyThrough": |
|
101 | - if(! $item['through'] && $item['model']){ |
|
102 | - $item['through'] = $this->prependNamespace($item['model']); |
|
103 | - $item['model'] = $this->prependNamespace($item['name']); |
|
104 | - } else { |
|
105 | - $item['through'] = $this->prependNamespace($item['through']); |
|
106 | - $item['model'] = $this->prependNamespace($item['model']); |
|
107 | - } |
|
108 | - break; |
|
109 | - case "morphMany": |
|
110 | - case "morphToMany": |
|
111 | - case "morphedByMany": |
|
112 | - if(! $item['through']){ |
|
113 | - $item['through'] = $item['model']; |
|
114 | - $item['model'] = $this->prependNamespace($item['name']); |
|
115 | - } else { |
|
116 | - $item['model'] = $this->prependNamespace($item['model']); |
|
117 | - } |
|
118 | - break; |
|
119 | - |
|
120 | - } |
|
121 | - } |
|
96 | + if ($parser == 'relations') { |
|
97 | + $item['model'] = $this->prependNamespace($item['model'] ?: $item['name']); |
|
98 | + } else if ($parser != 'relations') { |
|
99 | + switch($type) { |
|
100 | + case "hasManyThrough": |
|
101 | + if(! $item['through'] && $item['model']){ |
|
102 | + $item['through'] = $this->prependNamespace($item['model']); |
|
103 | + $item['model'] = $this->prependNamespace($item['name']); |
|
104 | + } else { |
|
105 | + $item['through'] = $this->prependNamespace($item['through']); |
|
106 | + $item['model'] = $this->prependNamespace($item['model']); |
|
107 | + } |
|
108 | + break; |
|
109 | + case "morphMany": |
|
110 | + case "morphToMany": |
|
111 | + case "morphedByMany": |
|
112 | + if(! $item['through']){ |
|
113 | + $item['through'] = $item['model']; |
|
114 | + $item['model'] = $this->prependNamespace($item['name']); |
|
115 | + } else { |
|
116 | + $item['model'] = $this->prependNamespace($item['model']); |
|
117 | + } |
|
118 | + break; |
|
119 | + |
|
120 | + } |
|
121 | + } |
|
122 | 122 | $relations[] = $template->with($item)->get(); |
123 | 123 | } |
124 | 124 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | protected function getRules() |
129 | 129 | { |
130 | 130 | $items = $this->parseValue($this->option('rules'), 'rules'); |
131 | - if ($items === false) { |
|
132 | - return $this->spaces(8) . "// Validation rules"; |
|
133 | - } |
|
131 | + if ($items === false) { |
|
132 | + return $this->spaces(8) . "// Validation rules"; |
|
133 | + } |
|
134 | 134 | |
135 | 135 | $template = $this->getTemplate('model/rule'); |
136 | 136 | $rules = []; |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | protected function getAsArrayFields($arg, $isOption = true) |
51 | 51 | { |
52 | 52 | $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); |
53 | - if(is_string($arg)){ |
|
53 | + if (is_string($arg)) { |
|
54 | 54 | $arg = explode(',', $arg); |
55 | - } else if(! is_array($arg)) { |
|
55 | + } else if (!is_array($arg)) { |
|
56 | 56 | $arg = []; |
57 | 57 | } |
58 | - return implode(', ', array_map(function($item){ |
|
58 | + return implode(', ', array_map(function($item) { |
|
59 | 59 | return '"' . $item . '"'; |
60 | 60 | }, $arg)); |
61 | 61 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $this->getRelationsByType('morphedByMany', 'morphed-by-many', false, 'relations-morphMany') |
75 | 75 | ); |
76 | 76 | |
77 | - if(empty($relations)){ |
|
77 | + if (empty($relations)) { |
|
78 | 78 | return " // Relationships"; |
79 | 79 | } |
80 | 80 | |
@@ -85,20 +85,20 @@ discard block |
||
85 | 85 | { |
86 | 86 | $relations = []; |
87 | 87 | $option = $this->option($option); |
88 | - if($option){ |
|
88 | + if ($option) { |
|
89 | 89 | |
90 | 90 | $items = $this->getArgumentParser($parser)->parse($option); |
91 | 91 | |
92 | - $template = ($withTimestamps) ? 'model/relation-with-timestamps' : ($parser=='relations'?'model/relation':'model/relation-'.$type); |
|
92 | + $template = ($withTimestamps) ? 'model/relation-with-timestamps' : ($parser == 'relations' ? 'model/relation' : 'model/relation-' . $type); |
|
93 | 93 | $template = $this->getTemplate($template); |
94 | 94 | foreach ($items as $item) { |
95 | 95 | $item['type'] = $type; |
96 | 96 | if ($parser == 'relations') { |
97 | 97 | $item['model'] = $this->prependNamespace($item['model'] ?: $item['name']); |
98 | 98 | } else if ($parser != 'relations') { |
99 | - switch($type) { |
|
99 | + switch ($type) { |
|
100 | 100 | case "hasManyThrough": |
101 | - if(! $item['through'] && $item['model']){ |
|
101 | + if (!$item['through'] && $item['model']) { |
|
102 | 102 | $item['through'] = $this->prependNamespace($item['model']); |
103 | 103 | $item['model'] = $this->prependNamespace($item['name']); |
104 | 104 | } else { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | case "morphMany": |
110 | 110 | case "morphToMany": |
111 | 111 | case "morphedByMany": |
112 | - if(! $item['through']){ |
|
112 | + if (!$item['through']) { |
|
113 | 113 | $item['through'] = $item['model']; |
114 | 114 | $item['model'] = $this->prependNamespace($item['name']); |
115 | 115 | } else { |