We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | * - when true: `address[street]` |
20 | 20 | * - when false: `[address][street]` |
21 | 21 | */ |
22 | -if (! Str::hasMacro('dotsToSquareBrackets')) { |
|
23 | - Str::macro('dotsToSquareBrackets', function ($string, $ignore = [], $keyFirst = true) { |
|
22 | +if (!Str::hasMacro('dotsToSquareBrackets')) { |
|
23 | + Str::macro('dotsToSquareBrackets', function($string, $ignore = [], $keyFirst = true) { |
|
24 | 24 | $stringParts = explode('.', $string); |
25 | 25 | $result = ''; |
26 | 26 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | return $result; |
35 | 35 | }); |
36 | 36 | } |
37 | -if (! CrudColumn::hasMacro('withUploads')) { |
|
38 | - CrudColumn::macro('withUploads', function ($uploadDefinition = []) { |
|
37 | +if (!CrudColumn::hasMacro('withUploads')) { |
|
38 | + CrudColumn::macro('withUploads', function($uploadDefinition = []) { |
|
39 | 39 | /** @var CrudField|CrudColumn $this */ |
40 | 40 | RegisterUploadEvents::handle($this, $uploadDefinition); |
41 | 41 | |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | }); |
44 | 44 | } |
45 | 45 | |
46 | -if (! CrudField::hasMacro('withUploads')) { |
|
47 | - CrudField::macro('withUploads', function ($uploadDefinition = []) { |
|
46 | +if (!CrudField::hasMacro('withUploads')) { |
|
47 | + CrudField::macro('withUploads', function($uploadDefinition = []) { |
|
48 | 48 | /** @var CrudField|CrudColumn $this */ |
49 | 49 | RegisterUploadEvents::handle($this, $uploadDefinition); |
50 | 50 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | * |
59 | 59 | * It will go to the given CrudController and get the setupRoutes() method on it. |
60 | 60 | */ |
61 | -if (! Route::hasMacro('crud')) { |
|
62 | - Route::macro('crud', function ($name, $controller) { |
|
61 | +if (!Route::hasMacro('crud')) { |
|
62 | + Route::macro('crud', function($name, $controller) { |
|
63 | 63 | // put together the route name prefix, |
64 | 64 | // as passed to the Route::group() statements |
65 | 65 | $routeName = ''; |
@@ -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); |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | * @param UploaderInterface|RepeatableUploaderInterface $uploader |
59 | 59 | * @return void |
60 | 60 | */ |
61 | - private function setupModelEvents(string $model, UploaderInterface|RepeatableUploaderInterface $uploader): void |
|
61 | + private function setupModelEvents(string $model, UploaderInterface | RepeatableUploaderInterface $uploader): void |
|
62 | 62 | { |
63 | 63 | if (app('UploadStore')->isUploadHandled($uploader->getName())) { |
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($uploader->getCrudObjectType() === 'field') { |
68 | - $model::saving(function ($entry) use ($uploader) { |
|
68 | + $model::saving(function($entry) use ($uploader) { |
|
69 | 69 | $updatedCountKey = 'uploaded_'.$uploader->getName().'_count'; |
70 | 70 | |
71 | 71 | CRUD::set($updatedCountKey, CRUD::get($updatedCountKey) ?? 0); |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | }); |
77 | 77 | } |
78 | 78 | |
79 | - $model::retrieved(function ($entry) use ($uploader) { |
|
79 | + $model::retrieved(function($entry) use ($uploader) { |
|
80 | 80 | $entry = $uploader->retrieveUploadedFile($entry); |
81 | 81 | }); |
82 | 82 | |
83 | - $model::deleting(function ($entry) use ($uploader) { |
|
83 | + $model::deleting(function($entry) use ($uploader) { |
|
84 | 84 | if (is_a($uploader, RepeatableUploaderInterface::class)) { |
85 | 85 | $uploader->deleteUploadedFile($entry); |
86 | 86 | |
87 | 87 | return; |
88 | 88 | } |
89 | 89 | if ($uploader->deleteWhenEntryIsDeleted) { |
90 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
90 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
91 | 91 | $uploader->deleteUploadedFile($entry); |
92 | 92 | } else { |
93 | 93 | if ($entry->forceDeleting === true) { |
@@ -120,8 +120,7 @@ discard block |
||
120 | 120 | $subfielduploadDefinition = $subfield['withUploads'] ?? $subfield['withMedia']; |
121 | 121 | |
122 | 122 | $subfielduploadDefinition = is_array($subfielduploadDefinition) ? |
123 | - array_merge($uploadDefinition, $subfielduploadDefinition) : |
|
124 | - $uploadDefinition; |
|
123 | + array_merge($uploadDefinition, $subfielduploadDefinition) : $uploadDefinition; |
|
125 | 124 | |
126 | 125 | $uploaderType = $this->getUploader($subfield, $subfielduploadDefinition); |
127 | 126 | |
@@ -130,7 +129,7 @@ discard block |
||
130 | 129 | } |
131 | 130 | |
132 | 131 | foreach ($repeatableDefinitions as $model => $uploaderTypes) { |
133 | - $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable')::for($crudObject)->uploads(...$uploaderTypes); |
|
132 | + $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable')::for ($crudObject)->uploads(...$uploaderTypes); |
|
134 | 133 | $this->setupModelEvents($model, $repeatableDefinition); |
135 | 134 | } |
136 | 135 | } |
@@ -151,11 +150,11 @@ discard block |
||
151 | 150 | private function getUploader(array $crudObject, array $uploadDefinition) |
152 | 151 | { |
153 | 152 | if (isset($uploadDefinition['uploaderType'])) { |
154 | - return $uploadDefinition['uploaderType']::for($crudObject, $uploadDefinition); |
|
153 | + return $uploadDefinition['uploaderType']::for ($crudObject, $uploadDefinition); |
|
155 | 154 | } |
156 | 155 | |
157 | 156 | if (app('UploadStore')->hasUploadFor($crudObject['type'])) { |
158 | - return app('UploadStore')->getUploadFor($crudObject['type'])::for($crudObject, $uploadDefinition); |
|
157 | + return app('UploadStore')->getUploadFor($crudObject['type'])::for ($crudObject, $uploadDefinition); |
|
159 | 158 | } |
160 | 159 | |
161 | 160 | throw new Exception('Undefined upload type for '.$crudObject['crudObjectType'].' type: '.$crudObject['type']); |
@@ -168,7 +167,7 @@ discard block |
||
168 | 167 | * @param UploaderInterface $uploader |
169 | 168 | * @return void |
170 | 169 | */ |
171 | - private static function setupUploadConfigsInCrudObject(CrudField|CrudColumn $crudObject, UploaderInterface $uploader) |
|
170 | + private static function setupUploadConfigsInCrudObject(CrudField | CrudColumn $crudObject, UploaderInterface $uploader) |
|
172 | 171 | { |
173 | 172 | $crudObject->upload(true)->disk($uploader->disk)->prefix($uploader->path); |
174 | 173 | } |
@@ -130,7 +130,9 @@ |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | foreach ($repeatableDefinitions as $model => $uploaderTypes) { |
133 | - $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable')::for($crudObject)->uploads(...$uploaderTypes); |
|
133 | + $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable')::for($crudObject) { |
|
134 | + ->uploads(...$uploaderTypes); |
|
135 | + } |
|
134 | 136 | $this->setupModelEvents($model, $repeatableDefinition); |
135 | 137 | } |
136 | 138 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | { |
12 | 12 | public function save(Model $entry, $value = null) |
13 | 13 | { |
14 | - return $this->isRepeatable && ! $this->isRelationship ? $this->saveRepeatableSingleBase64($entry, $value) : $this->saveSingleBase64($entry, $value); |
|
14 | + return $this->isRepeatable && !$this->isRelationship ? $this->saveRepeatableSingleBase64($entry, $value) : $this->saveSingleBase64($entry, $value); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | private function saveSingleBase64($entry, $value) |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $value = $value ?? CRUD::getRequest()->get($this->name); |
20 | 20 | $previousImage = $entry->getOriginal($this->name); |
21 | 21 | |
22 | - if (! $value && $previousImage) { |
|
22 | + if (!$value && $previousImage) { |
|
23 | 23 | Storage::disk($this->disk)->delete($previousImage); |
24 | 24 | |
25 | 25 | return null; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $this->crudObjectType = $crudObject['crudObjectType']; |
25 | 25 | } |
26 | 26 | |
27 | - public static function for(array $crudObject) |
|
27 | + public static function for (array $crudObject) |
|
28 | 28 | { |
29 | 29 | if (isset($crudObject['relation_type']) && $crudObject['entity'] !== false) { |
30 | 30 | return new RepeatableRelationship($crudObject); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function uploads(...$uploads): self |
37 | 37 | { |
38 | 38 | foreach ($uploads as $upload) { |
39 | - if (! is_a($upload, UploaderInterface::class)) { |
|
39 | + if (!is_a($upload, UploaderInterface::class)) { |
|
40 | 40 | throw new \Exception('Uploads must be an instance of UploaderInterface.'); |
41 | 41 | } |
42 | 42 | $this->repeatableUploads[] = $upload->repeats($this->name)->relationship($this->isRelationship ?? false); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $uploadedValues = $upload->save($entry, $value->pluck($upload->getName())->toArray()); |
67 | 67 | |
68 | - $value = $value->map(function ($item, $key) use ($upload, $uploadedValues) { |
|
68 | + $value = $value->map(function($item, $key) use ($upload, $uploadedValues) { |
|
69 | 69 | $item[$upload->getName()] = $uploadedValues[$key] ?? null; |
70 | 70 | |
71 | 71 | return $item; |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | $crudField = CRUD::field($this->name); |
80 | 80 | |
81 | 81 | $subfields = collect($crudField->getAttributes()['subfields']); |
82 | - $subfields = $subfields->map(function ($item) { |
|
82 | + $subfields = $subfields->map(function($item) { |
|
83 | 83 | if (isset($item['withMedia']) || isset($item['withUploads'])) { |
84 | 84 | /** @var UploaderInterface $uploader */ |
85 | - $uploader = array_filter($this->repeatableUploads, function ($item) { |
|
85 | + $uploader = array_filter($this->repeatableUploads, function($item) { |
|
86 | 86 | return $item->name !== $this->name; |
87 | 87 | })[0]; |
88 | 88 | $item['upload'] = true; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | public function processFileUpload(Model $entry) |
104 | 104 | { |
105 | - if (! $this->isRelationship) { |
|
105 | + if (!$this->isRelationship) { |
|
106 | 106 | $entry->{$this->name} = json_encode($this->save($entry)); |
107 | 107 | } else { |
108 | 108 | $entry = $this->save($entry); |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | { |
131 | 131 | $repeatableValues = collect($entry->{$this->getName()}); |
132 | 132 | foreach ($this->repeatableUploads as $upload) { |
133 | - if (! $upload->deleteWhenEntryIsDeleted) { |
|
133 | + if (!$upload->deleteWhenEntryIsDeleted) { |
|
134 | 134 | continue; |
135 | 135 | } |
136 | 136 | $values = $repeatableValues->pluck($upload->getName())->toArray(); |
137 | 137 | foreach ($values as $value) { |
138 | - if (! $value) { |
|
138 | + if (!$value) { |
|
139 | 139 | continue; |
140 | 140 | } |
141 | 141 | if (is_array($value)) { |
@@ -54,7 +54,7 @@ |
||
54 | 54 | $values = $entry->{$upload->name}; |
55 | 55 | |
56 | 56 | if ($upload->isMultiple) { |
57 | - if (! isset($entry->getCasts()[$upload->name]) && is_string($values)) { |
|
57 | + if (!isset($entry->getCasts()[$upload->name]) && is_string($values)) { |
|
58 | 58 | $values = json_decode($values, true); |
59 | 59 | } |
60 | 60 | } else { |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | { |
195 | 195 | $value = $entry->{$this->name}; |
196 | 196 | |
197 | - if ($this->isMultiple && ! isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
197 | + if ($this->isMultiple && !isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
198 | 198 | $entry->{$this->name} = json_decode($value, true); |
199 | 199 | } else { |
200 | 200 | $entry->{$this->name} = Str::after($value, $this->path); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $values = $entry->{$this->name}; |
215 | 215 | |
216 | 216 | if ($this->isMultiple) { |
217 | - if (! isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
217 | + if (!isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
218 | 218 | $values = json_decode($values, true); |
219 | 219 | } |
220 | 220 | } else { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @param array $definition |
234 | 234 | * @return self |
235 | 235 | */ |
236 | - public static function for(array $crudObject, array $definition) |
|
236 | + public static function for (array $crudObject, array $definition) |
|
237 | 237 | { |
238 | 238 | return new static($crudObject, $definition); |
239 | 239 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | { |
297 | 297 | $items = CRUD::getRequest()->input('_order_'.$this->repeatableContainerName) ?? []; |
298 | 298 | |
299 | - array_walk($items, function (&$key, $value) { |
|
299 | + array_walk($items, function(&$key, $value) { |
|
300 | 300 | $requestValue = $key[$this->name] ?? null; |
301 | 301 | $key = $this->isMultiple ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
302 | 302 | }); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | protected function getPreviousRepeatableValues(Model $entry) |
324 | 324 | { |
325 | 325 | $previousValues = json_decode($entry->getOriginal($this->repeatableContainerName), true); |
326 | - if (! empty($previousValues)) { |
|
326 | + if (!empty($previousValues)) { |
|
327 | 327 | $previousValues = array_column($previousValues, $this->name); |
328 | 328 | } |
329 | 329 |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | |
10 | 10 | class MultipleFiles extends Uploader |
11 | 11 | { |
12 | - public static function for(array $field, $configuration) |
|
12 | + public static function for (array $field, $configuration) |
|
13 | 13 | { |
14 | 14 | return (new self($field, $configuration))->multiple(); |
15 | 15 | } |
16 | 16 | |
17 | 17 | public function save(Model $entry, $value = null) |
18 | 18 | { |
19 | - return $this->isRepeatable && ! $this->isRelationship ? $this->saveRepeatableMutipleFiles($entry, $value) : $this->saveMultipleFiles($entry, $value); |
|
19 | + return $this->isRepeatable && !$this->isRelationship ? $this->saveRepeatableMutipleFiles($entry, $value) : $this->saveMultipleFiles($entry, $value); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | private function saveMultipleFiles($entry, $value = null) |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | $previousFiles = $entry->getOriginal($this->name) ?? []; |
29 | 29 | |
30 | - if (! is_array($previousFiles) && is_string($previousFiles)) { |
|
30 | + if (!is_array($previousFiles) && is_string($previousFiles)) { |
|
31 | 31 | $previousFiles = json_decode($previousFiles, true); |
32 | 32 | } |
33 | 33 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | if (in_array($previousFile, $filesToDelete)) { |
37 | 37 | Storage::disk($this->disk)->delete($previousFile); |
38 | 38 | |
39 | - $previousFiles = Arr::where($previousFiles, function ($value, $key) use ($previousFile) { |
|
39 | + $previousFiles = Arr::where($previousFiles, function($value, $key) use ($previousFile) { |
|
40 | 40 | return $value != $previousFile; |
41 | 41 | }); |
42 | 42 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | { |
11 | 11 | public function save(Model $entry, $value = null) |
12 | 12 | { |
13 | - return $this->isRepeatable && ! $this->isRelationship ? $this->saveRepeatableFile($entry, $value) : $this->saveFile($entry, $value); |
|
13 | + return $this->isRepeatable && !$this->isRelationship ? $this->saveRepeatableFile($entry, $value) : $this->saveFile($entry, $value); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | private function saveRepeatableFile($entry, $values) |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | foreach ($previousFiles as $row => $file) { |
34 | - if ($file && ! isset($orderedFiles[$row])) { |
|
34 | + if ($file && !isset($orderedFiles[$row])) { |
|
35 | 35 | $orderedFiles[$row] = null; |
36 | 36 | Storage::disk($this->disk)->delete($file); |
37 | 37 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | return $this->path.$fileName; |
58 | 58 | } |
59 | 59 | |
60 | - if (! $value && CrudPanelFacade::getRequest()->has($this->name) && $previousFile) { |
|
60 | + if (!$value && CrudPanelFacade::getRequest()->has($this->name) && $previousFile) { |
|
61 | 61 | Storage::disk($this->disk)->delete($previousFile); |
62 | 62 | |
63 | 63 | return null; |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function deleteUploadedFile(Model $entry); |
14 | 14 | |
15 | - public static function for(array $field, array $configuration); |
|
15 | + public static function for (array $field, array $configuration); |
|
16 | 16 | |
17 | 17 | public function __construct(array $crudObject, array $configuration); |
18 | 18 |