We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -65,8 +65,8 @@ |
||
65 | 65 | // Next, We will check to see if the class already exists. If it does, we don't want |
66 | 66 | // to create the class and overwrite the user's code. So, we will bail out so the |
67 | 67 | // code is untouched. Otherwise, we will continue generating this class' files. |
68 | - if ((! $this->hasOption('force') || |
|
69 | - ! $this->option('force')) && |
|
68 | + if ((!$this->hasOption('force') || |
|
69 | + !$this->option('force')) && |
|
70 | 70 | $this->alreadyExists($class)) { |
71 | 71 | $this->closeProgressBlock('Already existed', 'yellow'); |
72 | 72 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | $this->progressBlock("Creating view <fg=blue>resources/views/{$filePath}.blade.php</>"); |
74 | 74 | |
75 | 75 | // check if the file already exists |
76 | - if ((! $this->hasOption('force') || ! $this->option('force')) && $this->alreadyExists($filePath)) { |
|
76 | + if ((!$this->hasOption('force') || !$this->option('force')) && $this->alreadyExists($filePath)) { |
|
77 | 77 | $this->closeProgressBlock('Already existed', 'yellow'); |
78 | 78 | |
79 | 79 | return false; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | // Next, We will check to see if the class already exists. If it does, we don't want |
59 | 59 | // to create the class and overwrite the user's code. So, we will bail out so the |
60 | 60 | // code is untouched. Otherwise, we will continue generating this class' files. |
61 | - if ((! $this->hasOption('force') || ! $this->option('force')) && $this->alreadyExists($this->getNameInput())) { |
|
61 | + if ((!$this->hasOption('force') || !$this->option('force')) && $this->alreadyExists($this->getNameInput())) { |
|
62 | 62 | $this->closeProgressBlock('Already existed', 'yellow'); |
63 | 63 | |
64 | 64 | return false; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | $name = str_replace($this->laravel->getNamespace(), '', $name); |
86 | 86 | |
87 | - return $this->laravel['path'].'/'.str_replace('\\', '/', $name).'CrudController.php'; |
|
87 | + return $this->laravel[ 'path' ].'/'.str_replace('\\', '/', $name).'CrudController.php'; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | protected function getAttributes($model) |
135 | 135 | { |
136 | - $attributes = []; |
|
136 | + $attributes = [ ]; |
|
137 | 137 | $model = new $model(); |
138 | 138 | |
139 | 139 | // if fillable was defined, use that as the attributes |
@@ -159,25 +159,25 @@ discard block |
||
159 | 159 | $class = Str::afterLast($name, '\\'); |
160 | 160 | $model = "App\\Models\\$class"; |
161 | 161 | |
162 | - if (! class_exists($model)) { |
|
162 | + if (!class_exists($model)) { |
|
163 | 163 | return $this; |
164 | 164 | } |
165 | 165 | |
166 | 166 | $attributes = $this->getAttributes($model); |
167 | - $fields = array_diff($attributes, ['id', 'created_at', 'updated_at', 'deleted_at']); |
|
168 | - $columns = array_diff($attributes, ['id']); |
|
167 | + $fields = array_diff($attributes, [ 'id', 'created_at', 'updated_at', 'deleted_at' ]); |
|
168 | + $columns = array_diff($attributes, [ 'id' ]); |
|
169 | 169 | $glue = PHP_EOL.' '; |
170 | 170 | |
171 | 171 | // create an array with the needed code for defining fields |
172 | 172 | $fields = collect($fields) |
173 | - ->map(function ($field) { |
|
173 | + ->map(function($field) { |
|
174 | 174 | return "CRUD::field('$field');"; |
175 | 175 | }) |
176 | 176 | ->join($glue); |
177 | 177 | |
178 | 178 | // create an array with the needed code for defining columns |
179 | 179 | $columns = collect($columns) |
180 | - ->map(function ($column) { |
|
180 | + ->map(function($column) { |
|
181 | 181 | return "CRUD::column('$column');"; |
182 | 182 | }) |
183 | 183 | ->join($glue); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | protected function replaceModel(&$stub, $name) |
200 | 200 | { |
201 | 201 | $class = str_replace($this->getNamespace($name).'\\', '', $name); |
202 | - $stub = str_replace(['DummyClass', '{{ class }}', '{{class}}'], $this->buildClassName($name), $stub); |
|
202 | + $stub = str_replace([ 'DummyClass', '{{ class }}', '{{class}}' ], $this->buildClassName($name), $stub); |
|
203 | 203 | |
204 | 204 | return $this; |
205 | 205 | } |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | { |
35 | 35 | // Validate validation option |
36 | 36 | $validation = $this->handleValidationOption(); |
37 | - if (! $validation) { |
|
37 | + if (!$validation) { |
|
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | |
41 | 41 | // make a list of all models |
42 | 42 | $models = $this->getModels(base_path('app')); |
43 | 43 | |
44 | - if (! count($models)) { |
|
44 | + if (!count($models)) { |
|
45 | 45 | $this->errorBlock('No models found.'); |
46 | 46 | |
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | 50 | foreach ($models as $model) { |
51 | - $this->call('backpack:crud', ['name' => $model, '--validation' => $validation]); |
|
51 | + $this->call('backpack:crud', [ 'name' => $model, '--validation' => $validation ]); |
|
52 | 52 | $this->line(' <fg=gray>----------</>'); |
53 | 53 | } |
54 | 54 | |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | |
58 | 58 | private function getModels(string $path): array |
59 | 59 | { |
60 | - $out = []; |
|
60 | + $out = [ ]; |
|
61 | 61 | $results = scandir($path); |
62 | 62 | |
63 | 63 | foreach ($results as $result) { |
64 | 64 | $filepath = "$path/$result"; |
65 | 65 | |
66 | 66 | // ignore `.` (dot) prefixed files |
67 | - if ($result[0] === '.') { |
|
67 | + if ($result[ 0 ] === '.') { |
|
68 | 68 | continue; |
69 | 69 | } |
70 | 70 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | $result = $this->validateModelClass($class); |
85 | 85 | if ($result) { |
86 | - $out[] = $result; |
|
86 | + $out[ ] = $result; |
|
87 | 87 | continue; |
88 | 88 | } |
89 | 89 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $result = $this->validateModelClass("$namespace\\$classname"); |
96 | 96 | if ($result) { |
97 | - $out[] = $result; |
|
97 | + $out[ ] = $result; |
|
98 | 98 | continue; |
99 | 99 | } |
100 | 100 | } |
@@ -109,24 +109,24 @@ discard block |
||
109 | 109 | */ |
110 | 110 | private function handleValidationOption() |
111 | 111 | { |
112 | - $options = ['request', 'array', 'field']; |
|
112 | + $options = [ 'request', 'array', 'field' ]; |
|
113 | 113 | |
114 | 114 | // Validate validation option |
115 | 115 | $validation = $this->option('validation'); |
116 | 116 | |
117 | - if (! $validation) { |
|
117 | + if (!$validation) { |
|
118 | 118 | $validation = $this->askHint( |
119 | 119 | 'How would you like to define your validation rules, for the Create and Update operations?', [ |
120 | 120 | 'More info at <fg=blue>https://backpackforlaravel.com/docs/5.x/crud-operation-create#validation</>', |
121 | 121 | 'Valid options are <fg=blue>request</>, <fg=blue>array</> or <fg=blue>field</>', |
122 | - ], $options[0]); |
|
122 | + ], $options[ 0 ]); |
|
123 | 123 | |
124 | - if (! $this->option('no-interaction')) { |
|
124 | + if (!$this->option('no-interaction')) { |
|
125 | 125 | $this->deleteLines(5); |
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - if (! in_array($validation, $options)) { |
|
129 | + if (!in_array($validation, $options)) { |
|
130 | 130 | $this->errorBlock("The validation must be request, array or field. '$validation' is not valid."); |
131 | 131 | |
132 | 132 | return false; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | try { |
141 | 141 | $reflection = new \ReflectionClass($class); |
142 | 142 | |
143 | - if ($reflection->isSubclassOf(Model::class) && ! $reflection->isAbstract()) { |
|
143 | + if ($reflection->isSubclassOf(Model::class) && !$reflection->isAbstract()) { |
|
144 | 144 | return Str::of($class)->afterLast('\\'); |
145 | 145 | } |
146 | 146 | } catch (\Throwable$e) { |