We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $value = $value ?? CRUD::getRequest()->get($this->getName()); |
| 16 | 16 | $previousImage = $this->getPreviousFiles($entry); |
| 17 | 17 | |
| 18 | - if (! $value && $previousImage) { |
|
| 18 | + if (!$value && $previousImage) { |
|
| 19 | 19 | Storage::disk($this->getDisk())->delete($previousImage); |
| 20 | 20 | |
| 21 | 21 | return null; |
@@ -68,6 +68,6 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function shouldKeepPreviousValueUnchanged(Model $entry, $entryValue): bool |
| 70 | 70 | { |
| 71 | - return $entry->exists && is_string($entryValue) && ! Str::startsWith($entryValue, 'data:image'); |
|
| 71 | + return $entry->exists && is_string($entryValue) && !Str::startsWith($entryValue, 'data:image'); |
|
| 72 | 72 | } |
| 73 | 73 | } |
@@ -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 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $value = $this->mergeValuesRecursive($values, $files); |
| 56 | 56 | |
| 57 | 57 | if ($this->isRelationship()) { |
| 58 | - if($value->isEmpty()) { |
|
| 58 | + if ($value->isEmpty()) { |
|
| 59 | 59 | return $entry; |
| 60 | 60 | } |
| 61 | 61 | return $this->processRelationshipRepeatableUploaders($entry); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $uploader) { |
| 162 | 162 | $uploadedValues = $uploader->uploadRepeatableFiles($values->pluck($uploader->getAttributeName())->toArray(), $this->getPreviousRepeatableValues($entry, $uploader)); |
| 163 | 163 | |
| 164 | - $values = $values->map(function ($item, $key) use ($uploadedValues, $uploader) { |
|
| 164 | + $values = $values->map(function($item, $key) use ($uploadedValues, $uploader) { |
|
| 165 | 165 | $item[$uploader->getAttributeName()] = $uploadedValues[$key] ?? null; |
| 166 | 166 | |
| 167 | 167 | return $item; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $values = $entry->{$this->getRepeatableContainerName()}; |
| 194 | 194 | $values = is_string($values) ? json_decode($values, true) : $values; |
| 195 | - $values = array_map(function ($item) use ($repeatableUploaders) { |
|
| 195 | + $values = array_map(function($item) use ($repeatableUploaders) { |
|
| 196 | 196 | foreach ($repeatableUploaders as $upload) { |
| 197 | 197 | $item[$upload->getAttributeName()] = $this->getValuesWithPathStripped($item, $upload); |
| 198 | 198 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | private function retrieveRepeatableRelationFiles(Model $entry) |
| 209 | 209 | { |
| 210 | - switch($this->getRepeatableRelationType()) { |
|
| 210 | + switch ($this->getRepeatableRelationType()) { |
|
| 211 | 211 | case 'BelongsToMany': |
| 212 | 212 | case 'MorphToMany': |
| 213 | 213 | $pivotClass = app('crud')->getModel()->{$this->getUploaderSubfield()['baseEntity']}()->getPivotClass(); |
@@ -260,12 +260,12 @@ discard block |
||
| 260 | 260 | $repeatableValues ??= collect($entry->{$this->getRepeatableContainerName()}); |
| 261 | 261 | |
| 262 | 262 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $upload) { |
| 263 | - if (! $upload->shouldDeleteFiles()) { |
|
| 263 | + if (!$upload->shouldDeleteFiles()) { |
|
| 264 | 264 | continue; |
| 265 | 265 | } |
| 266 | 266 | $values = $repeatableValues->pluck($upload->getName())->toArray(); |
| 267 | 267 | foreach ($values as $value) { |
| 268 | - if (! $value) { |
|
| 268 | + if (!$value) { |
|
| 269 | 269 | continue; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | /** |
| 289 | 289 | * Given two multidimensional arrays/collections, merge them recursively. |
| 290 | 290 | */ |
| 291 | - protected function mergeValuesRecursive(array|Collection $array1, array|Collection $array2): array|Collection |
|
| 291 | + protected function mergeValuesRecursive(array | Collection $array1, array | Collection $array2): array | Collection |
|
| 292 | 292 | { |
| 293 | 293 | $merged = $array1; |
| 294 | 294 | foreach ($array2 as $key => &$value) { |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | { |
| 311 | 311 | $items = CRUD::getRequest()->input('_order_'.$this->getRepeatableContainerName()) ?? []; |
| 312 | 312 | |
| 313 | - array_walk($items, function (&$key, $value) { |
|
| 313 | + array_walk($items, function(&$key, $value) { |
|
| 314 | 314 | $requestValue = $key[$this->getName()] ?? null; |
| 315 | 315 | $key = $this->handleMultipleFiles ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
| 316 | 316 | }); |
@@ -322,22 +322,22 @@ discard block |
||
| 322 | 322 | { |
| 323 | 323 | $previousValues = $entry->getOriginal($uploader->getRepeatableContainerName()); |
| 324 | 324 | |
| 325 | - if (! is_array($previousValues)) { |
|
| 325 | + if (!is_array($previousValues)) { |
|
| 326 | 326 | $previousValues = json_decode($previousValues, true); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if (! empty($previousValues)) { |
|
| 329 | + if (!empty($previousValues)) { |
|
| 330 | 330 | $previousValues = array_column($previousValues, $uploader->getName()); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | return $previousValues ?? []; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - private function getValuesWithPathStripped(array|string|null $item, UploaderInterface $uploader) |
|
| 336 | + private function getValuesWithPathStripped(array | string | null $item, UploaderInterface $uploader) |
|
| 337 | 337 | { |
| 338 | 338 | $uploadedValues = $item[$uploader->getName()] ?? null; |
| 339 | 339 | if (is_array($uploadedValues)) { |
| 340 | - return array_map(function ($value) use ($uploader) { |
|
| 340 | + return array_map(function($value) use ($uploader) { |
|
| 341 | 341 | return $uploader->getValueWithoutPath($value); |
| 342 | 342 | }, $uploadedValues); |
| 343 | 343 | } |
@@ -347,8 +347,8 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | private function deleteRelationshipFiles(Model $entry): void |
| 349 | 349 | { |
| 350 | - if (! is_a($entry, Pivot::class, true) && |
|
| 351 | - ! $entry->relationLoaded($this->getRepeatableContainerName()) && |
|
| 350 | + if (!is_a($entry, Pivot::class, true) && |
|
| 351 | + !$entry->relationLoaded($this->getRepeatableContainerName()) && |
|
| 352 | 352 | method_exists($entry, $this->getRepeatableContainerName()) |
| 353 | 353 | ) { |
| 354 | 354 | $entry->loadMissing($this->getRepeatableContainerName()); |
@@ -382,9 +382,9 @@ discard block |
||
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - private function deletePivotFiles(Pivot|Model $entry) |
|
| 385 | + private function deletePivotFiles(Pivot | Model $entry) |
|
| 386 | 386 | { |
| 387 | - if (! is_a($entry, Pivot::class, true)) { |
|
| 387 | + if (!is_a($entry, Pivot::class, true)) { |
|
| 388 | 388 | $pivots = $entry->{$this->getRepeatableContainerName()}; |
| 389 | 389 | foreach ($pivots as $pivot) { |
| 390 | 390 | $this->deletePivotModelFiles($pivot); |
@@ -393,24 +393,24 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $pivotAttributes = $entry->getAttributes(); |
| 396 | - $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function ($item) use ($pivotAttributes) { |
|
| 396 | + $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function($item) use ($pivotAttributes) { |
|
| 397 | 397 | $itemPivotAttributes = $item->pivot->only(array_keys($pivotAttributes)); |
| 398 | 398 | |
| 399 | 399 | return $itemPivotAttributes === $pivotAttributes; |
| 400 | 400 | })->first(); |
| 401 | 401 | |
| 402 | - if (! $connectedPivot) { |
|
| 402 | + if (!$connectedPivot) { |
|
| 403 | 403 | return; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | $this->deletePivotModelFiles($connectedPivot); |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - private function deletePivotModelFiles(Pivot|Model $entry) |
|
| 409 | + private function deletePivotModelFiles(Pivot | Model $entry) |
|
| 410 | 410 | { |
| 411 | 411 | $files = $entry->getOriginal()['pivot_'.$this->getAttributeName()]; |
| 412 | 412 | |
| 413 | - if (! $files) { |
|
| 413 | + if (!$files) { |
|
| 414 | 414 | return; |
| 415 | 415 | } |
| 416 | 416 | |