@@ -67,7 +67,7 @@ |
||
67 | 67 | protected function getController() |
68 | 68 | { |
69 | 69 | $controller = $this->option('controller'); |
70 | - if(! $controller){ |
|
70 | + if (!$controller) { |
|
71 | 71 | $controller = ucwords(str_plural(camel_case($this->argument('resource')))) . 'Controller'; |
72 | 72 | } |
73 | 73 | return $controller; |
@@ -5,13 +5,13 @@ |
||
5 | 5 | |
6 | 6 | class RouteCommand extends BaseCommand { |
7 | 7 | |
8 | - protected $signature = 'wn:route |
|
8 | + protected $signature = 'wn:route |
|
9 | 9 | {resource : Name of the resource.} |
10 | 10 | {--controller= : Name of the RESTful controller.} |
11 | 11 | {--laravel= : Use Laravel style route definitions} |
12 | 12 | '; |
13 | 13 | |
14 | - protected $description = 'Generates RESTful routes.'; |
|
14 | + protected $description = 'Generates RESTful routes.'; |
|
15 | 15 | |
16 | 16 | public function handle() |
17 | 17 | { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | ]); |
62 | 62 | |
63 | 63 | // generating REST actions trait if doesn't exist |
64 | - if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){ |
|
64 | + if (!$this->fs->exists('./app/Http/Controllers/RESTActions.php')) { |
|
65 | 65 | $this->call('wn:controller:rest-actions'); |
66 | 66 | } |
67 | 67 | // generating the controller and routes |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | protected function parseFields() |
94 | 94 | { |
95 | 95 | $fields = $this->argument('fields'); |
96 | - if($this->option('parsed')){ |
|
96 | + if ($this->option('parsed')) { |
|
97 | 97 | $this->fields = $fields; |
98 | 98 | } else { |
99 | - if(! $fields){ |
|
99 | + if (!$fields) { |
|
100 | 100 | $this->fields = []; |
101 | 101 | } else { |
102 | 102 | $this->fields = $this->getArgumentParser('fields') |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | protected function fieldsHavingTag($tag) |
122 | 122 | { |
123 | - return array_map(function($field){ |
|
123 | + return array_map(function($field) { |
|
124 | 124 | return $field['name']; |
125 | 125 | }, array_filter($this->fields, function($field) use($tag){ |
126 | 126 | return in_array($tag, $field['tags']); |
@@ -129,19 +129,19 @@ discard block |
||
129 | 129 | |
130 | 130 | protected function rules() |
131 | 131 | { |
132 | - return array_map(function($field){ |
|
132 | + return array_map(function($field) { |
|
133 | 133 | return [ |
134 | 134 | 'name' => $field['name'], |
135 | 135 | 'rule' => $field['rules'] |
136 | 136 | ]; |
137 | - }, array_filter($this->fields, function($field){ |
|
137 | + }, array_filter($this->fields, function($field) { |
|
138 | 138 | return !empty($field['rules']); |
139 | 139 | })); |
140 | 140 | } |
141 | 141 | |
142 | 142 | protected function schema() |
143 | 143 | { |
144 | - return array_map(function($field){ |
|
144 | + return array_map(function($field) { |
|
145 | 145 | return array_merge([[ |
146 | 146 | 'name' => $field['name'], |
147 | 147 | 'args' => [] |
@@ -152,14 +152,14 @@ discard block |
||
152 | 152 | protected function foreignKeys() |
153 | 153 | { |
154 | 154 | $belongsTo = $this->option('belongs-to'); |
155 | - if(! $belongsTo) { |
|
155 | + if (!$belongsTo) { |
|
156 | 156 | return []; |
157 | 157 | } |
158 | 158 | $relations = $this->getArgumentParser('relations')->parse($belongsTo); |
159 | - return array_map(function($relation){ |
|
159 | + return array_map(function($relation) { |
|
160 | 160 | $name = $relation['model'] ? $relation['model'] : $relation['name']; |
161 | 161 | $index = strrpos($name, "\\"); |
162 | - if($index) { |
|
162 | + if ($index) { |
|
163 | 163 | $name = substr($name, $index + 1); |
164 | 164 | } |
165 | 165 | return snake_case(str_singular($name)) . '_id'; |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | |
181 | 181 | protected function factoryFields() |
182 | 182 | { |
183 | - return array_map(function($field){ |
|
183 | + return array_map(function($field) { |
|
184 | 184 | return [ |
185 | 185 | 'name' => $field['name'], |
186 | 186 | 'type' => $field['factory'] |
187 | 187 | ]; |
188 | - }, array_filter($this->fields, function($field){ |
|
188 | + }, array_filter($this->fields, function($field) { |
|
189 | 189 | return isset($field['factory']) && $field['factory']; |
190 | 190 | })); |
191 | 191 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | ->get(); |
35 | 35 | |
36 | 36 | $file = $this->option('file'); |
37 | - if(! $file){ |
|
37 | + if (!$file) { |
|
38 | 38 | $file = date('Y_m_d_His_') . $snakeName . '_table'; |
39 | 39 | $this->deleteOldMigration($snakeName); |
40 | - }else{ |
|
40 | + } else { |
|
41 | 41 | $this->deleteOldMigration($file); |
42 | 42 | } |
43 | 43 | |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | |
47 | 47 | protected function deleteOldMigration($fileName) |
48 | 48 | { |
49 | - foreach (new \DirectoryIterator("./database/migrations/") as $fileInfo){ |
|
50 | - if($fileInfo->isDot()) continue; |
|
49 | + foreach (new \DirectoryIterator("./database/migrations/") as $fileInfo) { |
|
50 | + if ($fileInfo->isDot()) continue; |
|
51 | 51 | |
52 | - if(strpos($fileInfo->getFilename(), $fileName) !== FALSE){ |
|
52 | + if (strpos($fileInfo->getFilename(), $fileName) !== FALSE) { |
|
53 | 53 | unlink($fileInfo->getPathname()); |
54 | 54 | } |
55 | 55 | } |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | protected function getSchema() |
59 | 59 | { |
60 | 60 | $schema = $this->option('schema'); |
61 | - if(! $schema){ |
|
61 | + if (!$schema) { |
|
62 | 62 | return $this->spaces(12) . "// Schema declaration"; |
63 | 63 | } |
64 | 64 | |
65 | 65 | $items = $schema; |
66 | - if( ! $this->option('parsed')){ |
|
66 | + if (!$this->option('parsed')) { |
|
67 | 67 | $items = $this->getArgumentParser('schema')->parse($schema); |
68 | 68 | } |
69 | 69 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $name = $parts[0]['name']; |
98 | 98 | $parts[1]['args'] = array_merge(["'{$name}'"], $parts[1]['args']); |
99 | 99 | unset($parts[0]); |
100 | - $parts = array_map(function($part){ |
|
100 | + $parts = array_map(function($part) { |
|
101 | 101 | return '->' . $part['name'] . '(' . implode(', ', $part['args']) . ')'; |
102 | 102 | }, $parts); |
103 | 103 | return " \$table" . implode('', $parts) . ';'; |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | protected function getConstraints() |
107 | 107 | { |
108 | 108 | $keys = $this->option('keys'); |
109 | - if(! $keys){ |
|
109 | + if (!$keys) { |
|
110 | 110 | return $this->spaces(12) . "// Constraints declaration"; |
111 | 111 | } |
112 | 112 | |
113 | 113 | $items = $keys; |
114 | - if(! $this->option('parsed')){ |
|
114 | + if (!$this->option('parsed')) { |
|
115 | 115 | $items = $this->getArgumentParser('foreign-keys')->parse($keys); |
116 | 116 | } |
117 | 117 | |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | |
126 | 126 | protected function getConstraintDeclaration($key) |
127 | 127 | { |
128 | - if(! $key['column']){ |
|
128 | + if (!$key['column']) { |
|
129 | 129 | $key['column'] = 'id'; |
130 | 130 | } |
131 | - if(! $key['table']){ |
|
131 | + if (!$key['table']) { |
|
132 | 132 | $key['table'] = str_plural(substr($key['name'], 0, count($key['name']) - 4)); |
133 | 133 | } |
134 | 134 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | ]) |
141 | 141 | ->get(); |
142 | 142 | |
143 | - if($key['on_delete']){ |
|
143 | + if ($key['on_delete']) { |
|
144 | 144 | $constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint') |
145 | 145 | ->with([ |
146 | 146 | 'event' => 'Delete', |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ->get(); |
150 | 150 | } |
151 | 151 | |
152 | - if($key['on_update']){ |
|
152 | + if ($key['on_update']) { |
|
153 | 153 | $constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint') |
154 | 154 | ->with([ |
155 | 155 | 'event' => 'Update', |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | if(! $file){ |
38 | 38 | $file = date('Y_m_d_His_') . $snakeName . '_table'; |
39 | 39 | $this->deleteOldMigration($snakeName); |
40 | - }else{ |
|
40 | + } else{ |
|
41 | 41 | $this->deleteOldMigration($file); |
42 | 42 | } |
43 | 43 | |
@@ -47,7 +47,9 @@ discard block |
||
47 | 47 | protected function deleteOldMigration($fileName) |
48 | 48 | { |
49 | 49 | foreach (new \DirectoryIterator("./database/migrations/") as $fileInfo){ |
50 | - if($fileInfo->isDot()) continue; |
|
50 | + if($fileInfo->isDot()) { |
|
51 | + continue; |
|
52 | + } |
|
51 | 53 | |
52 | 54 | if(strpos($fileInfo->getFilename(), $fileName) !== FALSE){ |
53 | 55 | unlink($fileInfo->getPathname()); |