We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | * @param CrudField|CrudColumn $macroable |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | - private function callRegisteredAttributeMacros(CrudField|CrudColumn $macroable) |
|
| 38 | + private function callRegisteredAttributeMacros(CrudField | CrudColumn $macroable) |
|
| 39 | 39 | { |
| 40 | 40 | $macros = $macroable->getMacros(); |
| 41 | 41 | $attributes = $macroable->getAttributes(); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function afterField($targetFieldName) |
| 140 | 140 | { |
| 141 | - $this->transformFields(function ($fields) use ($targetFieldName) { |
|
| 141 | + $this->transformFields(function($fields) use ($targetFieldName) { |
|
| 142 | 142 | return $this->moveField($fields, $targetFieldName, false); |
| 143 | 143 | }); |
| 144 | 144 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function beforeField($targetFieldName) |
| 152 | 152 | { |
| 153 | - $this->transformFields(function ($fields) use ($targetFieldName) { |
|
| 153 | + $this->transformFields(function($fields) use ($targetFieldName) { |
|
| 154 | 154 | return $this->moveField($fields, $targetFieldName, true); |
| 155 | 155 | }); |
| 156 | 156 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function makeFirstField() |
| 164 | 164 | { |
| 165 | - if (! $this->fields()) { |
|
| 165 | + if (!$this->fields()) { |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function removeField($name) |
| 179 | 179 | { |
| 180 | - $this->transformFields(function ($fields) use ($name) { |
|
| 180 | + $this->transformFields(function($fields) use ($name) { |
|
| 181 | 181 | Arr::forget($fields, $name); |
| 182 | 182 | |
| 183 | 183 | return $fields; |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function removeFields($array_of_names) |
| 193 | 193 | { |
| 194 | - if (! empty($array_of_names)) { |
|
| 194 | + if (!empty($array_of_names)) { |
|
| 195 | 195 | foreach ($array_of_names as $name) { |
| 196 | 196 | $this->removeField($name); |
| 197 | 197 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | public function removeAllFields() |
| 205 | 205 | { |
| 206 | 206 | $current_fields = $this->getCleanStateFields(); |
| 207 | - if (! empty($current_fields)) { |
|
| 207 | + if (!empty($current_fields)) { |
|
| 208 | 208 | foreach ($current_fields as $field) { |
| 209 | 209 | $this->removeField($field['name']); |
| 210 | 210 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $jsonCastables = ['array', 'object', 'json']; |
| 300 | 300 | $fieldCasting = $casted_attributes[$field['name']]; |
| 301 | 301 | |
| 302 | - if (in_array($fieldCasting, $jsonCastables) && isset($input[$field['name']]) && ! empty($input[$field['name']]) && ! is_array($input[$field['name']])) { |
|
| 302 | + if (in_array($fieldCasting, $jsonCastables) && isset($input[$field['name']]) && !empty($input[$field['name']]) && !is_array($input[$field['name']])) { |
|
| 303 | 303 | try { |
| 304 | 304 | $input[$field['name']] = json_decode($input[$field['name']]); |
| 305 | 305 | } catch (\Exception $e) { |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | public function orderFields($order) |
| 330 | 330 | { |
| 331 | - $this->transformFields(function ($fields) use ($order) { |
|
| 331 | + $this->transformFields(function($fields) use ($order) { |
|
| 332 | 332 | return $this->applyOrderToFields($fields, $order); |
| 333 | 333 | }); |
| 334 | 334 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | public function hasUploadFields() |
| 355 | 355 | { |
| 356 | 356 | $fields = $this->getCleanStateFields(); |
| 357 | - $upload_fields = Arr::where($fields, function ($value, $key) { |
|
| 357 | + $upload_fields = Arr::where($fields, function($value, $key) { |
|
| 358 | 358 | // check if any subfields have uploads |
| 359 | 359 | if (isset($value['subfields'])) { |
| 360 | 360 | foreach ($value['subfields'] as $subfield) { |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | $alreadyLoaded = $this->getLoadedFieldTypes(); |
| 427 | 427 | $type = $this->getFieldTypeWithNamespace($field); |
| 428 | 428 | |
| 429 | - if (! in_array($type, $this->getLoadedFieldTypes(), true)) { |
|
| 429 | + if (!in_array($type, $this->getLoadedFieldTypes(), true)) { |
|
| 430 | 430 | $alreadyLoaded[] = $type; |
| 431 | 431 | $this->setLoadedFieldTypes($alreadyLoaded); |
| 432 | 432 | |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | public function fieldTypeNotLoaded($field) |
| 469 | 469 | { |
| 470 | - return ! in_array($this->getFieldTypeWithNamespace($field), $this->getLoadedFieldTypes()); |
|
| 470 | + return !in_array($this->getFieldTypeWithNamespace($field), $this->getLoadedFieldTypes()); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | /** |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | */ |
| 517 | 517 | public function hasFieldWhere($attribute, $value) |
| 518 | 518 | { |
| 519 | - $match = Arr::first($this->getCleanStateFields(), function ($field, $fieldKey) use ($attribute, $value) { |
|
| 519 | + $match = Arr::first($this->getCleanStateFields(), function($field, $fieldKey) use ($attribute, $value) { |
|
| 520 | 520 | return isset($field[$attribute]) && $field[$attribute] == $value; |
| 521 | 521 | }); |
| 522 | 522 | |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | */ |
| 533 | 533 | public function firstFieldWhere($attribute, $value) |
| 534 | 534 | { |
| 535 | - return Arr::first($this->getCleanStateFields(), function ($field, $fieldKey) use ($attribute, $value) { |
|
| 535 | + return Arr::first($this->getCleanStateFields(), function($field, $fieldKey) use ($attribute, $value) { |
|
| 536 | 536 | return isset($field[$attribute]) && $field[$attribute] == $value; |
| 537 | 537 | }); |
| 538 | 538 | } |
@@ -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', $uploadDefinition['uploaders'] ?? null)::for($crudObject)->uploads(...$uploaderTypes); |
|
| 133 | + $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable', $uploadDefinition['uploaders'] ?? null)::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 | $uploaders = $uploadDefinition['uploaders'] ?? null; |
| 159 | 158 | if (app('UploadStore')->hasUploadFor($crudObject['type'], $uploaders)) { |
| 160 | - return app('UploadStore')->getUploadFor($crudObject['type'], $uploaders)::for($crudObject, $uploadDefinition); |
|
| 159 | + return app('UploadStore')->getUploadFor($crudObject['type'], $uploaders)::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 | } |
@@ -131,7 +131,9 @@ |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | foreach ($repeatableDefinitions as $model => $uploaderTypes) { |
| 134 | - $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable', $uploadDefinition['uploaders'] ?? null)::for($crudObject)->uploads(...$uploaderTypes); |
|
| 134 | + $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable', $uploadDefinition['uploaders'] ?? null)::for($crudObject) { |
|
| 135 | + ->uploads(...$uploaderTypes); |
|
| 136 | + } |
|
| 135 | 137 | $this->setupModelEvents($model, $repeatableDefinition); |
| 136 | 138 | } |
| 137 | 139 | } |