We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | final class RegisterUploadEvents |
| 13 | 13 | { |
| 14 | - public function __construct(private readonly CrudField|CrudColumn $crudObject, private readonly array $uploadDefinition) |
|
| 14 | + public function __construct(private readonly CrudField | CrudColumn $crudObject, private readonly array $uploadDefinition) |
|
| 15 | 15 | { |
| 16 | 16 | } |
| 17 | 17 | |
@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $crudObjectType = is_a($crudObject, CrudField::class) ? 'field' : (is_a($crudObject, CrudColumn::class) ? 'column' : null); |
| 36 | 36 | |
| 37 | - if (! $crudObjectType) { |
|
| 37 | + if (!$crudObjectType) { |
|
| 38 | 38 | abort(500, 'Upload handlers only work for CrudField and CrudColumn classes.'); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $attributes['crudObjectType'] = $crudObjectType; |
| 42 | 42 | |
| 43 | - if (! isset($attributes['subfields'])) { |
|
| 43 | + if (!isset($attributes['subfields'])) { |
|
| 44 | 44 | $uploaderType = $instance->getUploader($attributes, $uploadDefinition); |
| 45 | 45 | $instance->setupModelEvents($attributes['entryClass'], $uploaderType); |
| 46 | 46 | self::setupUploadConfigsInCrudObject($crudObject, $uploaderType); |
@@ -59,14 +59,14 @@ discard block |
||
| 59 | 59 | * @param UploaderInterface|RepeatableUploaderInterface $uploader |
| 60 | 60 | * @return void |
| 61 | 61 | */ |
| 62 | - private function setupModelEvents(string $model, UploaderInterface|RepeatableUploaderInterface $uploader): void |
|
| 62 | + private function setupModelEvents(string $model, UploaderInterface | RepeatableUploaderInterface $uploader): void |
|
| 63 | 63 | { |
| 64 | 64 | if (app('UploadStore')->isUploadHandled($uploader->getName())) { |
| 65 | 65 | return; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | if ($uploader->getCrudObjectType() === 'field') { |
| 69 | - $model::saving(function ($entry) use ($uploader) { |
|
| 69 | + $model::saving(function($entry) use ($uploader) { |
|
| 70 | 70 | $updatedCountKey = 'uploaded_'.$uploader->getName().'_count'; |
| 71 | 71 | |
| 72 | 72 | CRUD::set($updatedCountKey, CRUD::get($updatedCountKey) ?? 0); |
@@ -77,18 +77,18 @@ discard block |
||
| 77 | 77 | }); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - $model::retrieved(function ($entry) use ($uploader) { |
|
| 80 | + $model::retrieved(function($entry) use ($uploader) { |
|
| 81 | 81 | $entry = $uploader->retrieveUploadedFile($entry); |
| 82 | 82 | }); |
| 83 | 83 | |
| 84 | - $model::deleting(function ($entry) use ($uploader) { |
|
| 84 | + $model::deleting(function($entry) use ($uploader) { |
|
| 85 | 85 | if (is_a($uploader, RepeatableUploaderInterface::class)) { |
| 86 | 86 | $uploader->deleteUploadedFile($entry); |
| 87 | 87 | |
| 88 | 88 | return; |
| 89 | 89 | } |
| 90 | 90 | if ($uploader->deleteWhenEntryIsDeleted) { |
| 91 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
| 91 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
| 92 | 92 | $uploader->deleteUploadedFile($entry); |
| 93 | 93 | } else { |
| 94 | 94 | if ($entry->forceDeleting === true) { |
@@ -121,8 +121,7 @@ discard block |
||
| 121 | 121 | $subfielduploadDefinition = $subfield['withUploads'] ?? $subfield['withMedia']; |
| 122 | 122 | |
| 123 | 123 | $subfielduploadDefinition = is_array($subfielduploadDefinition) ? |
| 124 | - array_merge($uploadDefinition, $subfielduploadDefinition) : |
|
| 125 | - $uploadDefinition; |
|
| 124 | + array_merge($uploadDefinition, $subfielduploadDefinition) : $uploadDefinition; |
|
| 126 | 125 | |
| 127 | 126 | $uploaderType = $this->getUploader($subfield, $subfielduploadDefinition); |
| 128 | 127 | |
@@ -131,7 +130,7 @@ discard block |
||
| 131 | 130 | } |
| 132 | 131 | |
| 133 | 132 | foreach ($repeatableDefinitions as $model => $uploaderTypes) { |
| 134 | - $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable')::for($crudObject)->uploads(...$uploaderTypes); |
|
| 133 | + $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable')::for ($crudObject)->uploads(...$uploaderTypes); |
|
| 135 | 134 | $this->setupModelEvents($model, $repeatableDefinition); |
| 136 | 135 | } |
| 137 | 136 | } |
@@ -153,11 +152,11 @@ discard block |
||
| 153 | 152 | private function getUploader(array $crudObject, array $uploadDefinition) |
| 154 | 153 | { |
| 155 | 154 | if (isset($uploadDefinition['uploaderType'])) { |
| 156 | - return $uploadDefinition['uploaderType']::for($crudObject, $uploadDefinition); |
|
| 155 | + return $uploadDefinition['uploaderType']::for ($crudObject, $uploadDefinition); |
|
| 157 | 156 | } |
| 158 | 157 | |
| 159 | 158 | if (app('UploadStore')->hasUploadFor($crudObject['type'])) { |
| 160 | - return app('UploadStore')->getUploadFor($crudObject['type'])::for($crudObject, $uploadDefinition); |
|
| 159 | + return app('UploadStore')->getUploadFor($crudObject['type'])::for ($crudObject, $uploadDefinition); |
|
| 161 | 160 | } |
| 162 | 161 | |
| 163 | 162 | throw new Exception('Undefined upload type for '.$crudObject['crudObjectType'].' type: '.$crudObject['type']); |
@@ -170,7 +169,7 @@ discard block |
||
| 170 | 169 | * @param UploaderInterface $uploader |
| 171 | 170 | * @return void |
| 172 | 171 | */ |
| 173 | - private static function setupUploadConfigsInCrudObject(CrudField|CrudColumn $crudObject, UploaderInterface $uploader) |
|
| 172 | + private static function setupUploadConfigsInCrudObject(CrudField | CrudColumn $crudObject, UploaderInterface $uploader) |
|
| 174 | 173 | { |
| 175 | 174 | $crudObject->upload(true)->disk($uploader->disk)->prefix($uploader->path); |
| 176 | 175 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | $value = $entry->{$this->name}; |
| 194 | 194 | |
| 195 | - if ($this->isMultiple && ! isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
| 195 | + if ($this->isMultiple && !isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
| 196 | 196 | $entry->{$this->name} = json_decode($value, true); |
| 197 | 197 | } else { |
| 198 | 198 | $entry->{$this->name} = Str::after($value, $this->path); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $values = $entry->{$this->name}; |
| 213 | 213 | |
| 214 | 214 | if ($this->isMultiple) { |
| 215 | - if (! isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
| 215 | + if (!isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
| 216 | 216 | $values = json_decode($values, true); |
| 217 | 217 | } |
| 218 | 218 | } else { |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param array $definition |
| 232 | 232 | * @return self |
| 233 | 233 | */ |
| 234 | - public static function for(array $crudObject, array $definition) |
|
| 234 | + public static function for (array $crudObject, array $definition) |
|
| 235 | 235 | { |
| 236 | 236 | return new static($crudObject, $definition); |
| 237 | 237 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | { |
| 295 | 295 | $items = CRUD::getRequest()->input('_order_'.$this->repeatableContainerName) ?? []; |
| 296 | 296 | |
| 297 | - array_walk($items, function (&$key, $value) { |
|
| 297 | + array_walk($items, function(&$key, $value) { |
|
| 298 | 298 | $requestValue = $key[$this->name] ?? null; |
| 299 | 299 | $key = $this->isMultiple ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
| 300 | 300 | }); |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | protected function getPreviousRepeatableValues(Model $entry) |
| 322 | 322 | { |
| 323 | 323 | $previousValues = json_decode($entry->getOriginal($this->repeatableContainerName), true); |
| 324 | - if (! empty($previousValues)) { |
|
| 324 | + if (!empty($previousValues)) { |
|
| 325 | 325 | $previousValues = array_column($previousValues, $this->name); |
| 326 | 326 | } |
| 327 | 327 | |