We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -13,18 +13,18 @@ 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 | } |
| 26 | 26 | |
| 27 | - public static function handle(CrudField|CrudColumn $crudObject, array $uploaderConfiguration, string $macro, ?array $subfield = null): void |
|
| 27 | + public static function handle(CrudField | CrudColumn $crudObject, array $uploaderConfiguration, string $macro, ?array $subfield = null): void |
|
| 28 | 28 | { |
| 29 | 29 | $instance = new self($crudObject, $uploaderConfiguration, $macro); |
| 30 | 30 | |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | /******************************* |
| 35 | 35 | * Private methods - implementation |
| 36 | 36 | *******************************/ |
| 37 | - private function registerEvents(array|null $subfield = []): void |
|
| 37 | + private function registerEvents(array | null $subfield = []): void |
|
| 38 | 38 | { |
| 39 | - if (! empty($subfield)) { |
|
| 39 | + if (!empty($subfield)) { |
|
| 40 | 40 | $this->registerSubfieldEvent($subfield); |
| 41 | 41 | |
| 42 | 42 | return; |
@@ -71,12 +71,12 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // for subfields, we only register one event so that we have access to the repeatable container name. |
| 73 | 73 | // all the uploaders for a given container are stored in the UploadersRepository. |
| 74 | - if (! app('UploadersRepository')->hasRepeatableUploadersFor($uploader->getRepeatableContainerName())) { |
|
| 74 | + if (!app('UploadersRepository')->hasRepeatableUploadersFor($uploader->getRepeatableContainerName())) { |
|
| 75 | 75 | $this->setupModelEvents($model, $uploader); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $subfields = collect($this->crudObject->getAttributes()['subfields']); |
| 79 | - $subfields = $subfields->map(function ($item) use ($subfield, $uploader) { |
|
| 79 | + $subfields = $subfields->map(function($item) use ($subfield, $uploader) { |
|
| 80 | 80 | if ($item['name'] === $subfield['name']) { |
| 81 | 81 | $item['upload'] = true; |
| 82 | 82 | $item['disk'] = $uploader->getDisk(); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | if ($this->crudObjectType === 'field') { |
| 109 | - $model::saving(function ($entry) use ($uploader) { |
|
| 109 | + $model::saving(function($entry) use ($uploader) { |
|
| 110 | 110 | |
| 111 | 111 | $updatedCountKey = 'uploaded_'.($uploader->getRepeatableContainerName() ?? $uploader->getName()).'_count'; |
| 112 | 112 | |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | }); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - $model::retrieved(function ($entry) use ($uploader) { |
|
| 121 | + $model::retrieved(function($entry) use ($uploader) { |
|
| 122 | 122 | |
| 123 | 123 | $entry = $uploader->retrieveUploadedFiles($entry); |
| 124 | 124 | |
| 125 | 125 | }); |
| 126 | 126 | |
| 127 | - $model::deleting(function ($entry) use ($uploader) { |
|
| 127 | + $model::deleting(function($entry) use ($uploader) { |
|
| 128 | 128 | $uploader->deleteUploadedFiles($entry); |
| 129 | 129 | }); |
| 130 | 130 | |
@@ -146,13 +146,13 @@ discard block |
||
| 146 | 146 | $customUploader = isset($uploaderConfiguration['uploader']) && class_exists($uploaderConfiguration['uploader']); |
| 147 | 147 | |
| 148 | 148 | if ($customUploader) { |
| 149 | - return $uploaderConfiguration['uploader']::for($crudObject, $uploaderConfiguration); |
|
| 149 | + return $uploaderConfiguration['uploader']::for ($crudObject, $uploaderConfiguration); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $uploader = app('UploadersRepository')->hasUploadFor($crudObject['type'], $this->macro); |
| 153 | 153 | |
| 154 | 154 | if ($uploader) { |
| 155 | - return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for($crudObject, $uploaderConfiguration); |
|
| 155 | + return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for ($crudObject, $uploaderConfiguration); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | throw new Exception('Undefined upload type for '.$this->crudObjectType.' type: '.$crudObject['type']); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $uploader) { |
| 76 | 76 | $uploadedValues = $uploader->uploadRepeatableFiles($values->pluck($uploader->getName())->toArray(), $this->getPreviousRepeatableValues($entry, $uploader)); |
| 77 | 77 | |
| 78 | - $values = $values->map(function ($item, $key) use ($uploadedValues, $uploader) { |
|
| 78 | + $values = $values->map(function($item, $key) use ($uploadedValues, $uploader) { |
|
| 79 | 79 | $item[$uploader->getName()] = $uploadedValues[$key] ?? null; |
| 80 | 80 | |
| 81 | 81 | return $item; |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | $repeatableValues = collect($entry->{$this->getName()}); |
| 106 | 106 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $upload) { |
| 107 | - if (! $upload->shouldDeleteFiles()) { |
|
| 107 | + if (!$upload->shouldDeleteFiles()) { |
|
| 108 | 108 | continue; |
| 109 | 109 | } |
| 110 | 110 | $values = $repeatableValues->pluck($upload->getName())->toArray(); |
| 111 | 111 | foreach ($values as $value) { |
| 112 | - if (! $value) { |
|
| 112 | + if (!$value) { |
|
| 113 | 113 | continue; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | /** |
| 133 | 133 | * Given two multidimensional arrays/collections, merge them recursively. |
| 134 | 134 | */ |
| 135 | - protected function mergeValuesRecursive(array|Collection $array1, array|Collection $array2): array|Collection |
|
| 135 | + protected function mergeValuesRecursive(array | Collection $array1, array | Collection $array2): array | Collection |
|
| 136 | 136 | { |
| 137 | 137 | $merged = $array1; |
| 138 | 138 | foreach ($array2 as $key => &$value) { |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | { |
| 155 | 155 | $items = CRUD::getRequest()->input('_order_'.$this->getRepeatableContainerName()) ?? []; |
| 156 | 156 | |
| 157 | - array_walk($items, function (&$key, $value) { |
|
| 157 | + array_walk($items, function(&$key, $value) { |
|
| 158 | 158 | $requestValue = $key[$this->getName()] ?? null; |
| 159 | 159 | $key = $this->handleMultipleFiles ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
| 160 | 160 | }); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | $previousValues = json_decode($entry->getOriginal($uploader->getRepeatableContainerName()), true); |
| 168 | 168 | |
| 169 | - if (! empty($previousValues)) { |
|
| 169 | + if (!empty($previousValues)) { |
|
| 170 | 170 | $previousValues = array_column($previousValues, $uploader->getName()); |
| 171 | 171 | } |
| 172 | 172 | |