We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | { |
19 | 19 | public bool $handleRepeatableFiles = false; |
20 | 20 | |
21 | - public null|string $repeatableContainerName = null; |
|
21 | + public null | string $repeatableContainerName = null; |
|
22 | 22 | |
23 | 23 | /******************************* |
24 | 24 | * Setters - fluently configure the uploader |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /******************************* |
36 | 36 | * Getters |
37 | 37 | *******************************/ |
38 | - public function getRepeatableContainerName(): null|string |
|
38 | + public function getRepeatableContainerName(): null | string |
|
39 | 39 | { |
40 | 40 | return $this->repeatableContainerName; |
41 | 41 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $uploader) { |
164 | 164 | $uploadedValues = $uploader->uploadRepeatableFiles($values->pluck($uploader->getAttributeName())->toArray(), $this->getPreviousRepeatableValues($entry, $uploader)); |
165 | 165 | |
166 | - $values = $values->map(function ($item, $key) use ($uploadedValues, $uploader) { |
|
166 | + $values = $values->map(function($item, $key) use ($uploadedValues, $uploader) { |
|
167 | 167 | $item[$uploader->getAttributeName()] = $uploadedValues[$key] ?? null; |
168 | 168 | |
169 | 169 | return $item; |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | $values = $entry->{$this->getRepeatableContainerName()}; |
196 | 196 | $values = is_string($values) ? json_decode($values, true) : $values; |
197 | - $values = array_map(function ($item) use ($repeatableUploaders) { |
|
197 | + $values = array_map(function($item) use ($repeatableUploaders) { |
|
198 | 198 | foreach ($repeatableUploaders as $upload) { |
199 | 199 | $item[$upload->getAttributeName()] = $this->getValuesWithPathStripped($item, $upload); |
200 | 200 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | private function retrieveRepeatableRelationFiles(Model $entry) |
211 | 211 | { |
212 | - switch($this->getRepeatableRelationType()) { |
|
212 | + switch ($this->getRepeatableRelationType()) { |
|
213 | 213 | case 'BelongsToMany': |
214 | 214 | case 'MorphToMany': |
215 | 215 | $pivotClass = app('crud')->getModel()->{$this->getUploaderSubfield()['baseEntity']}()->getPivotClass(); |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | $repeatableValues ??= collect($entry->{$this->getRepeatableContainerName()}); |
263 | 263 | |
264 | 264 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $upload) { |
265 | - if (! $upload->shouldDeleteFiles()) { |
|
265 | + if (!$upload->shouldDeleteFiles()) { |
|
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | $values = $repeatableValues->pluck($upload->getName())->toArray(); |
269 | 269 | foreach ($values as $value) { |
270 | - if (! $value) { |
|
270 | + if (!$value) { |
|
271 | 271 | continue; |
272 | 272 | } |
273 | 273 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | /** |
291 | 291 | * Given two multidimensional arrays/collections, merge them recursively. |
292 | 292 | */ |
293 | - protected function mergeValuesRecursive(array|Collection $array1, array|Collection $array2): array|Collection |
|
293 | + protected function mergeValuesRecursive(array | Collection $array1, array | Collection $array2): array | Collection |
|
294 | 294 | { |
295 | 295 | $merged = $array1; |
296 | 296 | foreach ($array2 as $key => &$value) { |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | { |
313 | 313 | $items = CRUD::getRequest()->input('_order_'.$this->getRepeatableContainerName()) ?? []; |
314 | 314 | |
315 | - array_walk($items, function (&$key, $value) { |
|
315 | + array_walk($items, function(&$key, $value) { |
|
316 | 316 | $requestValue = $key[$this->getName()] ?? null; |
317 | 317 | $key = $this->handleMultipleFiles ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
318 | 318 | }); |
@@ -324,22 +324,22 @@ discard block |
||
324 | 324 | { |
325 | 325 | $previousValues = $entry->getOriginal($uploader->getRepeatableContainerName()); |
326 | 326 | |
327 | - if (! is_array($previousValues)) { |
|
327 | + if (!is_array($previousValues)) { |
|
328 | 328 | $previousValues = json_decode($previousValues, true); |
329 | 329 | } |
330 | 330 | |
331 | - if (! empty($previousValues)) { |
|
331 | + if (!empty($previousValues)) { |
|
332 | 332 | $previousValues = array_column($previousValues, $uploader->getName()); |
333 | 333 | } |
334 | 334 | |
335 | 335 | return $previousValues ?? []; |
336 | 336 | } |
337 | 337 | |
338 | - private function getValuesWithPathStripped(array|string|null $item, UploaderInterface $uploader) |
|
338 | + private function getValuesWithPathStripped(array | string | null $item, UploaderInterface $uploader) |
|
339 | 339 | { |
340 | 340 | $uploadedValues = $item[$uploader->getName()] ?? null; |
341 | 341 | if (is_array($uploadedValues)) { |
342 | - return array_map(function ($value) use ($uploader) { |
|
342 | + return array_map(function($value) use ($uploader) { |
|
343 | 343 | return $uploader->getValueWithoutPath($value); |
344 | 344 | }, $uploadedValues); |
345 | 345 | } |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | |
350 | 350 | private function deleteRelationshipFiles(Model $entry): void |
351 | 351 | { |
352 | - if(!is_a($entry, Pivot::class, true)) { |
|
352 | + if (!is_a($entry, Pivot::class, true)) { |
|
353 | 353 | $entry->loadMissing($this->getRepeatableContainerName()); |
354 | 354 | } |
355 | 355 | |
356 | 356 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $uploader) { |
357 | - if($uploader->shouldDeleteFiles()) { |
|
357 | + if ($uploader->shouldDeleteFiles()) { |
|
358 | 358 | $uploader->deleteRepeatableRelationFiles($entry); |
359 | 359 | } |
360 | 360 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | private function deleteRepeatableRelationFiles(Model $entry) |
364 | 364 | { |
365 | 365 | if (in_array($this->getRepeatableRelationType(), ['BelongsToMany', 'MorphToMany'])) { |
366 | - if(!is_a($entry, Pivot::class, true)) { |
|
366 | + if (!is_a($entry, Pivot::class, true)) { |
|
367 | 367 | $pivots = $entry->{$this->getRepeatableContainerName()}; |
368 | 368 | foreach ($pivots as $pivot) { |
369 | 369 | $this->deletePivotModelFiles($pivot); |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | } |
373 | 373 | |
374 | 374 | $pivotAttributes = $entry->getAttributes(); |
375 | - $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function ($item) use ($pivotAttributes) { |
|
375 | + $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function($item) use ($pivotAttributes) { |
|
376 | 376 | $itemPivotAttributes = $item->pivot->only(array_keys($pivotAttributes)); |
377 | 377 | |
378 | 378 | return $itemPivotAttributes === $pivotAttributes; |
379 | 379 | })->first(); |
380 | 380 | |
381 | - if (! $connectedPivot) { |
|
381 | + if (!$connectedPivot) { |
|
382 | 382 | return; |
383 | 383 | } |
384 | 384 | |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | $this->deleteFiles($entry); |
389 | 389 | } |
390 | 390 | |
391 | - private function deletePivotModelFiles(Pivot|Model $entry) |
|
391 | + private function deletePivotModelFiles(Pivot | Model $entry) |
|
392 | 392 | { |
393 | 393 | $files = $entry->getOriginal()['pivot_'.$this->getAttributeName()]; |
394 | 394 | |
395 | - if (! $files) { |
|
395 | + if (!$files) { |
|
396 | 396 | return; |
397 | 397 | } |
398 | 398 |