We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | private bool $deleteWhenEntryIsDeleted = true; |
27 | 27 | |
28 | - private bool|string $attachedToFakeField = false; |
|
28 | + private bool | string $attachedToFakeField = false; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Cloud disks have the ability to generate temporary URLs to files, should we do it? |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | /******************************* |
63 | 63 | * Static methods |
64 | 64 | *******************************/ |
65 | - public static function for(array $crudObject, array $definition): UploaderInterface |
|
65 | + public static function for (array $crudObject, array $definition): UploaderInterface |
|
66 | 66 | { |
67 | 67 | return new static($crudObject, $definition); |
68 | 68 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | public function deleteUploadedFiles(Model $entry): void |
104 | 104 | { |
105 | 105 | if ($this->deleteWhenEntryIsDeleted) { |
106 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
106 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
107 | 107 | $this->performFileDeletion($entry); |
108 | 108 | |
109 | 109 | return; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | public function getPreviousFiles(Model $entry): mixed |
181 | 181 | { |
182 | - if (! $this->attachedToFakeField) { |
|
182 | + if (!$this->attachedToFakeField) { |
|
183 | 183 | return $this->getOriginalValue($entry); |
184 | 184 | } |
185 | 185 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $value = $entry->{$this->getAttributeName()}; |
224 | 224 | |
225 | 225 | if ($this->handleMultipleFiles) { |
226 | - if (! isset($entry->getCasts()[$this->getName()]) && is_string($value)) { |
|
226 | + if (!isset($entry->getCasts()[$this->getName()]) && is_string($value)) { |
|
227 | 227 | $entry->{$this->getAttributeName()} = json_decode($value, true); |
228 | 228 | } |
229 | 229 | |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | { |
250 | 250 | $values = $entry->{$this->getAttributeName()}; |
251 | 251 | |
252 | - if(! $this->shouldDeleteFiles() || $values === null) |
|
252 | + if (!$this->shouldDeleteFiles() || $values === null) |
|
253 | 253 | { |
254 | 254 | return; |
255 | 255 | } |
256 | 256 | |
257 | 257 | if ($this->handleMultipleFiles) { |
258 | 258 | // ensure we have an array of values when field is not casted in model. |
259 | - if (! isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
259 | + if (!isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
260 | 260 | $values = json_decode($values, true); |
261 | 261 | } |
262 | 262 | foreach ($values ?? [] as $value) { |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | private function performFileDeletion(Model $entry) |
275 | 275 | { |
276 | - if (! $this->handleRepeatableFiles) { |
|
276 | + if (!$this->handleRepeatableFiles) { |
|
277 | 277 | $this->deleteFiles($entry); |
278 | 278 | |
279 | 279 | return; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | $previousValue = $entry->getOriginal($field); |
304 | 304 | |
305 | - if (! $previousValue) { |
|
305 | + if (!$previousValue) { |
|
306 | 306 | return $previousValue; |
307 | 307 | } |
308 | 308 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | public bool $handleRepeatableFiles = false; |
16 | 16 | |
17 | - public null|string $repeatableContainerName = null; |
|
17 | + public null | string $repeatableContainerName = null; |
|
18 | 18 | |
19 | 19 | /******************************* |
20 | 20 | * Setters - fluently configure the uploader |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | /******************************* |
32 | 32 | * Getters |
33 | 33 | *******************************/ |
34 | - public function getRepeatableContainerName(): null|string |
|
34 | + public function getRepeatableContainerName(): null | string |
|
35 | 35 | { |
36 | 36 | return $this->repeatableContainerName; |
37 | 37 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $uploader) { |
139 | 139 | $uploadedValues = $uploader->uploadRepeatableFiles($values->pluck($uploader->getAttributeName())->toArray(), $this->getPreviousRepeatableValues($entry, $uploader)); |
140 | 140 | |
141 | - $values = $values->map(function ($item, $key) use ($uploadedValues, $uploader) { |
|
141 | + $values = $values->map(function($item, $key) use ($uploadedValues, $uploader) { |
|
142 | 142 | $item[$uploader->getAttributeName()] = $uploadedValues[$key] ?? null; |
143 | 143 | |
144 | 144 | return $item; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | $values = $entry->{$this->getRepeatableContainerName()}; |
160 | 160 | $values = is_string($values) ? json_decode($values, true) : $values; |
161 | - $values = array_map(function ($item) use ($repeatableUploaders) { |
|
161 | + $values = array_map(function($item) use ($repeatableUploaders) { |
|
162 | 162 | foreach ($repeatableUploaders as $upload) { |
163 | 163 | $item[$upload->getAttributeName()] = $this->getValuesWithPathStripped($item, $upload); |
164 | 164 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | |
174 | 174 | private function retrieveRepeatableRelationFiles(Model $entry) |
175 | 175 | { |
176 | - switch($this->getRepeatableRelationType()) { |
|
176 | + switch ($this->getRepeatableRelationType()) { |
|
177 | 177 | case 'BelongsToMany': |
178 | 178 | case 'MorphToMany': |
179 | 179 | $pivotClass = app('crud')->getModel()->{$this->getUploaderSubfield()['baseEntity']}()->getPivotClass(); |
@@ -220,12 +220,12 @@ discard block |
||
220 | 220 | $repeatableValues = collect($entry->{$this->getRepeatableContainerName()}); |
221 | 221 | |
222 | 222 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $upload) { |
223 | - if (! $upload->shouldDeleteFiles()) { |
|
223 | + if (!$upload->shouldDeleteFiles()) { |
|
224 | 224 | continue; |
225 | 225 | } |
226 | 226 | $values = $repeatableValues->pluck($upload->getName())->toArray(); |
227 | 227 | foreach ($values as $value) { |
228 | - if (! $value) { |
|
228 | + if (!$value) { |
|
229 | 229 | continue; |
230 | 230 | } |
231 | 231 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | /** |
249 | 249 | * Given two multidimensional arrays/collections, merge them recursively. |
250 | 250 | */ |
251 | - protected function mergeValuesRecursive(array|Collection $array1, array|Collection $array2): array|Collection |
|
251 | + protected function mergeValuesRecursive(array | Collection $array1, array | Collection $array2): array | Collection |
|
252 | 252 | { |
253 | 253 | $merged = $array1; |
254 | 254 | foreach ($array2 as $key => &$value) { |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | { |
271 | 271 | $items = CRUD::getRequest()->input('_order_'.$this->getRepeatableContainerName()) ?? []; |
272 | 272 | |
273 | - array_walk($items, function (&$key, $value) { |
|
273 | + array_walk($items, function(&$key, $value) { |
|
274 | 274 | $requestValue = $key[$this->getName()] ?? null; |
275 | 275 | $key = $this->handleMultipleFiles ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
276 | 276 | }); |
@@ -282,22 +282,22 @@ discard block |
||
282 | 282 | { |
283 | 283 | $previousValues = $entry->getOriginal($uploader->getRepeatableContainerName()); |
284 | 284 | |
285 | - if (! is_array($previousValues)) { |
|
285 | + if (!is_array($previousValues)) { |
|
286 | 286 | $previousValues = json_decode($previousValues, true); |
287 | 287 | } |
288 | 288 | |
289 | - if (! empty($previousValues)) { |
|
289 | + if (!empty($previousValues)) { |
|
290 | 290 | $previousValues = array_column($previousValues, $uploader->getName()); |
291 | 291 | } |
292 | 292 | |
293 | 293 | return $previousValues ?? []; |
294 | 294 | } |
295 | 295 | |
296 | - private function getValuesWithPathStripped(array|string|null $item, UploaderInterface $uploader) |
|
296 | + private function getValuesWithPathStripped(array | string | null $item, UploaderInterface $uploader) |
|
297 | 297 | { |
298 | 298 | $uploadedValues = $item[$uploader->getName()] ?? null; |
299 | 299 | if (is_array($uploadedValues)) { |
300 | - return array_map(function ($value) use ($uploader) { |
|
300 | + return array_map(function($value) use ($uploader) { |
|
301 | 301 | return $uploader->getValueWithoutPath($value); |
302 | 302 | }, $uploadedValues); |
303 | 303 | } |
@@ -316,19 +316,19 @@ discard block |
||
316 | 316 | { |
317 | 317 | if (in_array($this->getRepeatableRelationType(), ['BelongsToMany', 'MorphToMany'])) { |
318 | 318 | $pivotAttributes = $entry->getAttributes(); |
319 | - $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function ($item) use ($pivotAttributes) { |
|
319 | + $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function($item) use ($pivotAttributes) { |
|
320 | 320 | $itemPivotAttributes = $item->pivot->only(array_keys($pivotAttributes)); |
321 | 321 | |
322 | 322 | return $itemPivotAttributes === $pivotAttributes; |
323 | 323 | })->first(); |
324 | 324 | |
325 | - if (! $connectedPivot) { |
|
325 | + if (!$connectedPivot) { |
|
326 | 326 | return; |
327 | 327 | } |
328 | 328 | |
329 | 329 | $files = $connectedPivot->getOriginal()['pivot_'.$this->getAttributeName()]; |
330 | 330 | |
331 | - if (! $files) { |
|
331 | + if (!$files) { |
|
332 | 332 | return; |
333 | 333 | } |
334 | 334 |