We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | private string $crudObjectType; |
14 | 14 | |
15 | 15 | public function __construct( |
16 | - private readonly CrudField|CrudColumn $crudObject, |
|
16 | + private readonly CrudField | CrudColumn $crudObject, |
|
17 | 17 | private readonly array $uploaderConfiguration, |
18 | 18 | private readonly string $macro |
19 | 19 | ) { |
20 | 20 | $this->crudObjectType = is_a($crudObject, CrudField::class) ? 'field' : (is_a($crudObject, CrudColumn::class) ? 'column' : null); |
21 | 21 | |
22 | - if (! $this->crudObjectType) { |
|
22 | + if (!$this->crudObjectType) { |
|
23 | 23 | abort(500, 'Upload handlers only work for CrudField and CrudColumn classes.'); |
24 | 24 | } |
25 | 25 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | if ($this->crudObjectType === 'field') { |
59 | - $model::saving(function ($entry) use ($uploader) { |
|
59 | + $model::saving(function($entry) use ($uploader) { |
|
60 | 60 | $updatedCountKey = 'uploaded_'.($uploader->getRepeatableContainerName() ?? $uploader->getName()).'_count'; |
61 | 61 | |
62 | 62 | CRUD::set($updatedCountKey, CRUD::get($updatedCountKey) ?? 0); |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | }); |
70 | 70 | } |
71 | 71 | |
72 | - $model::retrieved(function ($entry) use ($uploader) { |
|
72 | + $model::retrieved(function($entry) use ($uploader) { |
|
73 | 73 | $entry = $uploader->retrieveUploadedFile($entry); |
74 | 74 | }); |
75 | 75 | |
76 | - $model::deleting(function ($entry) use ($uploader) { |
|
76 | + $model::deleting(function($entry) use ($uploader) { |
|
77 | 77 | $uploader->deleteUploadedFile($entry); |
78 | 78 | }); |
79 | 79 | |
80 | 80 | app('UploadersRepository')->markAsHandled($uploader->getIdentifier()); |
81 | 81 | } |
82 | 82 | |
83 | - public function registerEvents(array|null $subfield = []) |
|
83 | + public function registerEvents(array | null $subfield = []) |
|
84 | 84 | { |
85 | - if (! empty($subfield)) { |
|
85 | + if (!empty($subfield)) { |
|
86 | 86 | return $this->registerSubfieldEvent($subfield); |
87 | 87 | } |
88 | 88 | |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | |
121 | 121 | // for subfields, we only register one event so that we have access to the repeatable container name. |
122 | 122 | // all the uploaders for a given container are stored in the UploadersRepository. |
123 | - if (! app('UploadersRepository')->hasUploadersRegisteredFor($uploader->getRepeatableContainerName())) { |
|
123 | + if (!app('UploadersRepository')->hasUploadersRegisteredFor($uploader->getRepeatableContainerName())) { |
|
124 | 124 | $this->setupModelEvents($model, $uploader); |
125 | 125 | } |
126 | 126 | |
127 | 127 | $subfields = collect($this->crudObject->getAttributes()['subfields']); |
128 | - $subfields = $subfields->map(function ($item) use ($subfield, $uploader) { |
|
128 | + $subfields = $subfields->map(function($item) use ($subfield, $uploader) { |
|
129 | 129 | if ($item['name'] === $subfield['name']) { |
130 | 130 | $item['upload'] = true; |
131 | 131 | $item['disk'] = $uploader->getDisk(); |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | private function getUploader(array $crudObject, array $uploaderConfiguration) |
162 | 162 | { |
163 | 163 | if (isset($uploaderConfiguration['uploaderType'])) { |
164 | - return $uploaderConfiguration['uploaderType']::for($crudObject, $uploaderConfiguration); |
|
164 | + return $uploaderConfiguration['uploaderType']::for ($crudObject, $uploaderConfiguration); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | if (app('UploadersRepository')->hasUploadFor($crudObject['type'], $this->macro)) { |
168 | - return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for($crudObject, $uploaderConfiguration); |
|
168 | + return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for ($crudObject, $uploaderConfiguration); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | throw new Exception('Undefined upload type for '.$this->crudObjectType.' type: '.$crudObject['type']); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | $value = $this->mergeValuesRecursive($values, $files); |
155 | 155 | |
156 | - if (! $this->isRelationship) { |
|
156 | + if (!$this->isRelationship) { |
|
157 | 157 | $entry->{$this->repeatableContainerName} = json_encode($this->processRepeatableUploads($entry, $value)); |
158 | 158 | } else { |
159 | 159 | $modelCount = CRUD::get('uploaded_'.$this->repeatableContainerName.'_count'); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | foreach (app('UploadersRepository')->getRegisteredUploadersFor($this->repeatableContainerName) as $uploader) { |
176 | 176 | $uploadedValues = $uploader->uploadRepeatableFile($entry, $value->pluck($uploader->name)->toArray()); |
177 | 177 | |
178 | - $value = $value->map(function ($item, $key) use ($uploadedValues, $uploader) { |
|
178 | + $value = $value->map(function($item, $key) use ($uploadedValues, $uploader) { |
|
179 | 179 | $item[$uploader->getName()] = $uploadedValues[$key] ?? null; |
180 | 180 | |
181 | 181 | return $item; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | { |
255 | 255 | $value = $entry->{$this->name}; |
256 | 256 | |
257 | - if ($this->isMultiple && ! isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
257 | + if ($this->isMultiple && !isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
258 | 258 | $entry->{$this->name} = json_decode($value, true); |
259 | 259 | } else { |
260 | 260 | $entry->{$this->name} = Str::after($value, $this->path); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | public function deleteUploadedFile(Model $entry) |
282 | 282 | { |
283 | 283 | if ($this->deleteWhenEntryIsDeleted) { |
284 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
284 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
285 | 285 | $this->performFileDeletion($entry); |
286 | 286 | } else { |
287 | 287 | if ($entry->forceDeleting === true) { |
@@ -299,12 +299,12 @@ discard block |
||
299 | 299 | |
300 | 300 | $repeatableValues = collect($entry->{$this->getName()}); |
301 | 301 | foreach (app('UploadersRepository')->getRegisteredUploadersFor($this->repeatableContainerName) as $upload) { |
302 | - if (! $upload->deleteWhenEntryIsDeleted) { |
|
302 | + if (!$upload->deleteWhenEntryIsDeleted) { |
|
303 | 303 | continue; |
304 | 304 | } |
305 | 305 | $values = $repeatableValues->pluck($upload->getName())->toArray(); |
306 | 306 | foreach ($values as $value) { |
307 | - if (! $value) { |
|
307 | + if (!$value) { |
|
308 | 308 | continue; |
309 | 309 | } |
310 | 310 | if (is_array($value)) { |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $values = $entry->{$this->name}; |
325 | 325 | |
326 | 326 | if ($this->isMultiple) { |
327 | - if (! isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
327 | + if (!isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
328 | 328 | $values = json_decode($values, true); |
329 | 329 | } |
330 | 330 | } else { |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * @param array $definition |
353 | 353 | * @return self |
354 | 354 | */ |
355 | - public static function for(array $crudObject, array $definition) |
|
355 | + public static function for (array $crudObject, array $definition) |
|
356 | 356 | { |
357 | 357 | return new static($crudObject, $definition); |
358 | 358 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | { |
410 | 410 | $items = CRUD::getRequest()->input('_order_'.$this->repeatableContainerName) ?? []; |
411 | 411 | |
412 | - array_walk($items, function (&$key, $value) { |
|
412 | + array_walk($items, function(&$key, $value) { |
|
413 | 413 | $requestValue = $key[$this->name] ?? null; |
414 | 414 | $key = $this->isMultiple ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
415 | 415 | }); |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | protected function getPreviousRepeatableValues(Model $entry) |
437 | 437 | { |
438 | 438 | $previousValues = json_decode($entry->getOriginal($this->repeatableContainerName), true); |
439 | - if (! empty($previousValues)) { |
|
439 | + if (!empty($previousValues)) { |
|
440 | 440 | $previousValues = array_column($previousValues, $this->name); |
441 | 441 | } |
442 | 442 |