We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | // always have a hidden input for the entry id |
61 | - if (! array_key_exists('id', $fields)) { |
|
61 | + if (!array_key_exists('id', $fields)) { |
|
62 | 62 | $fields['id'] = [ |
63 | 63 | 'name' => $entry->getKeyName(), |
64 | 64 | 'value' => $entry->getKey(), |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | $fieldEntity = $field['entity'] ?? false; |
84 | 84 | $fakeField = $field['fake'] ?? false; |
85 | 85 | |
86 | - if ($fieldEntity && ! $fakeField) { |
|
86 | + if ($fieldEntity && !$fakeField) { |
|
87 | 87 | return $this->getModelAttributeValueFromRelationship($model, $field); |
88 | 88 | } |
89 | 89 | |
90 | 90 | if ($this->holdsMultipleInputs($field['name'])) { |
91 | - $result = array_map(function ($item) use ($model) { |
|
91 | + $result = array_map(function($item) use ($model) { |
|
92 | 92 | return $model->{$item}; |
93 | 93 | }, explode(',', $field['name'])); |
94 | 94 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | { |
111 | 111 | [$relatedModel, $relationMethod] = $this->getModelAndMethodFromEntity($model, $field); |
112 | 112 | |
113 | - if (! method_exists($relatedModel, $relationMethod)) { |
|
113 | + if (!method_exists($relatedModel, $relationMethod)) { |
|
114 | 114 | return $relatedModel->{$relationMethod}; |
115 | 115 | } |
116 | 116 | |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | case 'HasMany': |
123 | 123 | case 'BelongsToMany': |
124 | 124 | case 'MorphToMany': |
125 | - if( |
|
125 | + if ( |
|
126 | 126 | ($relationType == 'BelongsToMany' || $relationType == 'MorphToMany') && |
127 | 127 | $relatedModel->{$relationMethod}->count() > 0 && |
128 | - $relatedModel->{$relationMethod}[0]->{$relatedModel->{$relationMethod}()->getRelatedPivotKeyName()}){ |
|
128 | + $relatedModel->{$relationMethod}[0]->{$relatedModel->{$relationMethod}()->getRelatedPivotKeyName()}) { |
|
129 | 129 | $key = $relatedModel->{$relationMethod}[0]->{$relatedModel->{$relationMethod}()->getRelatedPivotKeyName()}->getKeyName(); |
130 | 130 | $relationModels = $relatedModel->{$relationMethod}()->withPivot($key)->get(); |
131 | 131 | } else { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $model = $this->setupRelatedModelLocale($model); |
138 | 138 | // when subfields are NOT set we don't need to get any more values |
139 | 139 | // we just return the plain models as we only need the ids |
140 | - if (! isset($field['subfields'])) { |
|
140 | + if (!isset($field['subfields'])) { |
|
141 | 141 | $result->push($model); |
142 | 142 | |
143 | 143 | continue; |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | break; |
166 | 166 | case 'HasOne': |
167 | 167 | case 'MorphOne': |
168 | - if (! method_exists($relatedModel, $relationMethod)) { |
|
168 | + if (!method_exists($relatedModel, $relationMethod)) { |
|
169 | 169 | return; |
170 | 170 | } |
171 | 171 | |
172 | 172 | $model = $relatedModel->{$relationMethod}; |
173 | 173 | |
174 | - if (! $model) { |
|
174 | + if (!$model) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | 177 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | $relationArray = explode('.', $relationEntity); |
254 | 254 | |
255 | - $relatedModel = array_reduce(array_splice($relationArray, 0, -1), function ($obj, $method) { |
|
255 | + $relatedModel = array_reduce(array_splice($relationArray, 0, -1), function($obj, $method) { |
|
256 | 256 | // if the string ends with `_id` we strip it out |
257 | 257 | $method = Str::endsWith($method, '_id') ? Str::replaceLast('_id', '', $method) : $method; |
258 | 258 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | // if the subfield name does not contain a dot we just need to check |
280 | 280 | // if it has subfields and return the result accordingly. |
281 | 281 | foreach ((array) $subfield['name'] as $name) { |
282 | - if (! Str::contains($name, '.')) { |
|
282 | + if (!Str::contains($name, '.')) { |
|
283 | 283 | // when subfields are present, $relatedModel->{$name} returns a model instance |
284 | 284 | // otherwise returns the model attribute. |
285 | 285 | if ($relatedModel->{$name}) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | // - a single dimensional array: [1,2,3] |
123 | 123 | // - an array of arrays: [[1][2][3]] |
124 | 124 | // if is as single dimensional array we can only attach. |
125 | - if ($relationValues === null || ! is_multidimensional_array($relationValues)) { |
|
125 | + if ($relationValues === null || !is_multidimensional_array($relationValues)) { |
|
126 | 126 | $this->attachManyRelation($item, $relation, $relationDetails, $relationValues); |
127 | 127 | } else { |
128 | 128 | $this->createManyEntries($item, $relation, $relationMethod, $relationDetails); |
@@ -154,15 +154,15 @@ discard block |
||
154 | 154 | if (empty($relationValues)) { |
155 | 155 | $relationValues = array_values($values); |
156 | 156 | } |
157 | - if($item->{$relationMethod}->count() > 0 && is_multidimensional_array($values)) { |
|
157 | + if ($item->{$relationMethod}->count() > 0 && is_multidimensional_array($values)) { |
|
158 | 158 | // get the key name of the pivot table (usually id, but could be something else if the dev has set it in the model |
159 | 159 | $keyName = $item->{$relationMethod}[0]->pivot->getKeyName(); |
160 | 160 | $items = $item->{$relationMethod}()->withPivot($keyName)->get(); |
161 | - $items->each(function ($item) use (&$relationValues, $keyName, $relationMethod) { |
|
162 | - if($item->pivot){ |
|
161 | + $items->each(function($item) use (&$relationValues, $keyName, $relationMethod) { |
|
162 | + if ($item->pivot) { |
|
163 | 163 | $keys = array_column($relationValues, $keyName); |
164 | 164 | $key = $item->pivot->{$keyName}; |
165 | - if(!in_array((int) $key, $keys)) { |
|
165 | + if (!in_array((int) $key, $keys)) { |
|
166 | 166 | $item->pivot->delete(); |
167 | 167 | } else { |
168 | 168 | $index = array_search($key, $keys); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | } |
317 | 317 | // if column is not nullable in database, and there is no column default (null), |
318 | 318 | // we will delete the entry from the database, otherwise it will throw and ugly DB error. |
319 | - if (! $relationColumnIsNullable && $dbColumnDefault === null) { |
|
319 | + if (!$relationColumnIsNullable && $dbColumnDefault === null) { |
|
320 | 320 | return $removedEntries->lazy()->each->delete(); |
321 | 321 | } |
322 | 322 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | } |
362 | 362 | |
363 | 363 | // use the collection of sent ids to match against database ids, delete the ones not found in the submitted ids. |
364 | - if (! empty($relatedItemsSent)) { |
|
364 | + if (!empty($relatedItemsSent)) { |
|
365 | 365 | // we perform the cleanup of removed database items |
366 | 366 | $entry->{$relationMethod}()->whereNotIn($relatedModelLocalKey, $relatedItemsSent)->lazy()->each->delete(); |
367 | 367 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | return ['name' => Str::replace(' ', '', $field)]; |
116 | 116 | } |
117 | 117 | |
118 | - if (is_array($field) && ! isset($field['name'])) { |
|
118 | + if (is_array($field) && !isset($field['name'])) { |
|
119 | 119 | abort(500, 'All fields must have their name defined'); |
120 | 120 | } |
121 | 121 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | } |
190 | 190 | // if there's a model defined, but no attribute |
191 | 191 | // guess an attribute using the identifiableAttribute functionality in CrudTrait |
192 | - if (isset($field['model']) && ! isset($field['attribute']) && method_exists($field['model'], 'identifiableAttribute')) { |
|
192 | + if (isset($field['model']) && !isset($field['attribute']) && method_exists($field['model'], 'identifiableAttribute')) { |
|
193 | 193 | $field['attribute'] = (new $field['model']())->identifiableAttribute(); |
194 | 194 | } |
195 | 195 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | protected function makeSureFieldHasLabel($field) |
207 | 207 | { |
208 | - if (! isset($field['label'])) { |
|
208 | + if (!isset($field['label'])) { |
|
209 | 209 | $name = str_replace(',', ' ', $field['name']); |
210 | 210 | $name = str_replace('_id', '', $name); |
211 | 211 | $field['label'] = mb_ucfirst(str_replace('_', ' ', $name)); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | protected function makeSureFieldHasType($field) |
225 | 225 | { |
226 | - if (! isset($field['type'])) { |
|
226 | + if (!isset($field['type'])) { |
|
227 | 227 | $field['type'] = isset($field['relation_type']) ? $this->inferFieldTypeFromRelationType($field['relation_type']) : $this->inferFieldTypeFromDbColumnType($field['name']); |
228 | 228 | } |
229 | 229 | |
@@ -256,16 +256,16 @@ discard block |
||
256 | 256 | */ |
257 | 257 | protected function makeSureSubfieldsHaveNecessaryAttributes($field) |
258 | 258 | { |
259 | - if (! isset($field['subfields']) || ! is_array($field['subfields'])) { |
|
259 | + if (!isset($field['subfields']) || !is_array($field['subfields'])) { |
|
260 | 260 | return $field; |
261 | 261 | } |
262 | 262 | |
263 | - if (! is_multidimensional_array($field['subfields'], true)) { |
|
263 | + if (!is_multidimensional_array($field['subfields'], true)) { |
|
264 | 264 | abort(500, 'Subfields of «'.$field['name'].'» are malformed. Make sure you provide an array of subfields.'); |
265 | 265 | } |
266 | 266 | |
267 | 267 | foreach ($field['subfields'] as $key => $subfield) { |
268 | - if (empty($subfield) || ! isset($subfield['name'])) { |
|
268 | + if (empty($subfield) || !isset($subfield['name'])) { |
|
269 | 269 | abort(500, 'A subfield of «'.$field['name'].'» is malformed. Subfield attribute name can\'t be empty.'); |
270 | 270 | } |
271 | 271 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | |
279 | 279 | $subfield['parentFieldName'] = $field['name']; |
280 | 280 | |
281 | - if (! isset($field['model'])) { |
|
281 | + if (!isset($field['model'])) { |
|
282 | 282 | // we're inside a simple 'repeatable' with no model/relationship, so |
283 | 283 | // we assume all subfields are supposed to be text fields |
284 | 284 | $subfield['type'] = $subfield['type'] ?? 'text'; |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | ]); |
315 | 315 | $pivotSelectorField = static::getPivotFieldStructure($field); |
316 | 316 | |
317 | - $pivot = Arr::where($field['subfields'], function ($item) use ($pivotSelectorField) { |
|
317 | + $pivot = Arr::where($field['subfields'], function($item) use ($pivotSelectorField) { |
|
318 | 318 | return $item['name'] === $pivotSelectorField['name']; |
319 | 319 | }); |
320 | 320 | |
321 | - if (! empty($pivot)) { |
|
321 | + if (!empty($pivot)) { |
|
322 | 322 | break; |
323 | 323 | } |
324 | 324 | |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | $entity = isset($field['baseEntity']) ? $field['baseEntity'].'.'.$field['entity'] : $field['entity']; |
332 | 332 | $relationInstance = $this->getRelationInstance(['entity' => $entity]); |
333 | 333 | |
334 | - $localKeyField = Arr::where($field['subfields'], function ($item) use ($relationInstance) { |
|
334 | + $localKeyField = Arr::where($field['subfields'], function($item) use ($relationInstance) { |
|
335 | 335 | return $item['name'] === $relationInstance->getRelated()->getKeyName(); |
336 | 336 | }); |
337 | 337 | |
338 | - if (! empty($localKeyField)) { |
|
338 | + if (!empty($localKeyField)) { |
|
339 | 339 | break; |
340 | 340 | } |
341 | 341 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | { |
361 | 361 | // if a tab was mentioned, we should enable it |
362 | 362 | if (isset($field['tab'])) { |
363 | - if (! $this->tabsEnabled()) { |
|
363 | + if (!$this->tabsEnabled()) { |
|
364 | 364 | $this->enableTabs(); |
365 | 365 | } |
366 | 366 | } |