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,16 +34,16 @@ discard block |
||
34 | 34 | return $result; |
35 | 35 | }); |
36 | 36 | } |
37 | -if (! CrudColumn::hasMacro('withFiles')) { |
|
38 | - CrudColumn::macro('withFiles', function ($uploadDefinition = [], $subfield = null) { |
|
37 | +if (!CrudColumn::hasMacro('withFiles')) { |
|
38 | + CrudColumn::macro('withFiles', function($uploadDefinition = [], $subfield = null) { |
|
39 | 39 | /** @var CrudField|CrudColumn $this */ |
40 | 40 | RegisterUploadEvents::handle($this, $uploadDefinition, 'withFiles', $subfield); |
41 | 41 | return $this; |
42 | 42 | }); |
43 | 43 | } |
44 | 44 | |
45 | -if (! CrudField::hasMacro('withFiles')) { |
|
46 | - CrudField::macro('withFiles', function ($uploadDefinition = [], $subfield = null) { |
|
45 | +if (!CrudField::hasMacro('withFiles')) { |
|
46 | + CrudField::macro('withFiles', function($uploadDefinition = [], $subfield = null) { |
|
47 | 47 | /** @var CrudField|CrudColumn $this */ |
48 | 48 | RegisterUploadEvents::handle($this, $uploadDefinition, 'withFiles', $subfield); |
49 | 49 | return $this; |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * |
57 | 57 | * It will go to the given CrudController and get the setupRoutes() method on it. |
58 | 58 | */ |
59 | -if (! Route::hasMacro('crud')) { |
|
60 | - Route::macro('crud', function ($name, $controller) { |
|
59 | +if (!Route::hasMacro('crud')) { |
|
60 | + Route::macro('crud', function($name, $controller) { |
|
61 | 61 | // put together the route name prefix, |
62 | 62 | // as passed to the Route::group() statements |
63 | 63 | $routeName = ''; |
@@ -74,7 +74,7 @@ |
||
74 | 74 | }); |
75 | 75 | |
76 | 76 | $model::deleting(function ($entry) use ($uploader) { |
77 | - $uploader->deleteUploadedFile($entry); |
|
77 | + $uploader->deleteUploadedFile($entry); |
|
78 | 78 | }); |
79 | 79 | |
80 | 80 | app('UploadersRepository')->markAsHandled($uploader->getIdentifier()); |
@@ -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,11 +69,11 @@ 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 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | public function registerEvents(array $subfield = []) |
84 | 84 | { |
85 | - if(!empty($subfield)) { |
|
85 | + if (!empty($subfield)) { |
|
86 | 86 | return $this->registerSubfieldEvent($subfield); |
87 | 87 | } |
88 | 88 | |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | |
122 | 122 | // for subfields, we only register one event so that we have access to the repeatable container name. |
123 | 123 | // all the uploaders for a given container are stored in the UploadersRepository. |
124 | - if (! app('UploadersRepository')->hasUploadersRegisteredFor($uploader->getRepeatableContainerName())) { |
|
124 | + if (!app('UploadersRepository')->hasUploadersRegisteredFor($uploader->getRepeatableContainerName())) { |
|
125 | 125 | $this->setupModelEvents($model, $uploader); |
126 | 126 | } |
127 | 127 | |
128 | 128 | $subfields = collect($this->crudObject->getAttributes()['subfields']); |
129 | - $subfields = $subfields->map(function ($item) use ($subfield, $uploader) { |
|
129 | + $subfields = $subfields->map(function($item) use ($subfield, $uploader) { |
|
130 | 130 | if ($item['name'] === $subfield['name']) { |
131 | 131 | $item['upload'] = true; |
132 | 132 | $item['disk'] = $uploader->getDisk(); |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | private function getUploader(array $crudObject, array $uploaderConfiguration) |
164 | 164 | { |
165 | 165 | if (isset($uploaderConfiguration['uploaderType'])) { |
166 | - return $uploaderConfiguration['uploaderType']::for($crudObject, $uploaderConfiguration); |
|
166 | + return $uploaderConfiguration['uploaderType']::for ($crudObject, $uploaderConfiguration); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | if (app('UploadersRepository')->hasUploadFor($crudObject['type'], $this->macro)) { |
170 | - return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for($crudObject, $uploaderConfiguration); |
|
170 | + return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for ($crudObject, $uploaderConfiguration); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | throw new Exception('Undefined upload type for '.$crudObject['crudObjectType'].' type: '.$crudObject['type']); |
@@ -9,7 +9,7 @@ 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 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | $previousFiles = $entry->getOriginal($this->name) ?? []; |
24 | 24 | |
25 | - if (! is_array($previousFiles) && is_string($previousFiles)) { |
|
25 | + if (!is_array($previousFiles) && is_string($previousFiles)) { |
|
26 | 26 | $previousFiles = json_decode($previousFiles, true); |
27 | 27 | } |
28 | 28 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | if (in_array($previousFile, $filesToDelete)) { |
32 | 32 | Storage::disk($this->disk)->delete($previousFile); |
33 | 33 | |
34 | - $previousFiles = Arr::where($previousFiles, function ($value, $key) use ($previousFile) { |
|
34 | + $previousFiles = Arr::where($previousFiles, function($value, $key) use ($previousFile) { |
|
35 | 35 | return $value != $previousFile; |
36 | 36 | }); |
37 | 37 | } |
@@ -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->saveRepeatableFile($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) { |
@@ -293,18 +293,18 @@ discard block |
||
293 | 293 | |
294 | 294 | private function deleteRepeatableFiles($entry) |
295 | 295 | { |
296 | - if($this->isRelationship) { |
|
296 | + if ($this->isRelationship) { |
|
297 | 297 | return $this->deleteFiles($entry); |
298 | 298 | } |
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 { |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | |
340 | 340 | private function performFileDeletion($entry) |
341 | 341 | { |
342 | - if( $this->isRelationship) { |
|
342 | + if ($this->isRelationship) { |
|
343 | 343 | return $this->deleteFiles($entry); |
344 | 344 | } |
345 | 345 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param array $definition |
354 | 354 | * @return self |
355 | 355 | */ |
356 | - public static function for(array $crudObject, array $definition) |
|
356 | + public static function for (array $crudObject, array $definition) |
|
357 | 357 | { |
358 | 358 | return new static($crudObject, $definition); |
359 | 359 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | { |
411 | 411 | $items = CRUD::getRequest()->input('_order_'.$this->repeatableContainerName) ?? []; |
412 | 412 | |
413 | - array_walk($items, function (&$key, $value) { |
|
413 | + array_walk($items, function(&$key, $value) { |
|
414 | 414 | $requestValue = $key[$this->name] ?? null; |
415 | 415 | $key = $this->isMultiple ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
416 | 416 | }); |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | protected function getPreviousRepeatableValues(Model $entry) |
438 | 438 | { |
439 | 439 | $previousValues = json_decode($entry->getOriginal($this->repeatableContainerName), true); |
440 | - if (! empty($previousValues)) { |
|
440 | + if (!empty($previousValues)) { |
|
441 | 441 | $previousValues = array_column($previousValues, $this->name); |
442 | 442 | } |
443 | 443 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | foreach ($previousFiles as $row => $file) { |
29 | - if ($file && ! isset($orderedFiles[$row])) { |
|
29 | + if ($file && !isset($orderedFiles[$row])) { |
|
30 | 30 | $orderedFiles[$row] = null; |
31 | 31 | Storage::disk($this->disk)->delete($file); |
32 | 32 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | return $this->path.$fileName; |
53 | 53 | } |
54 | 54 | |
55 | - if (! $value && CrudPanelFacade::getRequest()->has($this->name) && $previousFile) { |
|
55 | + if (!$value && CrudPanelFacade::getRequest()->has($this->name) && $previousFile) { |
|
56 | 56 | Storage::disk($this->disk)->delete($previousFile); |
57 | 57 | |
58 | 58 | return null; |
@@ -14,7 +14,7 @@ |
||
14 | 14 | $value = $value ?? CRUD::getRequest()->get($this->name); |
15 | 15 | $previousImage = $entry->getOriginal($this->name); |
16 | 16 | |
17 | - if (! $value && $previousImage) { |
|
17 | + if (!$value && $previousImage) { |
|
18 | 18 | Storage::disk($this->disk)->delete($previousImage); |
19 | 19 | |
20 | 20 | return null; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | public function markAsHandled(string $objectName) |
19 | 19 | { |
20 | - if (! in_array($objectName, $this->handledUploaders)) { |
|
20 | + if (!in_array($objectName, $this->handledUploaders)) { |
|
21 | 21 | $this->handledUploaders[] = $objectName; |
22 | 22 | } |
23 | 23 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | public function registerUploader(string $uploadName, $uploader) |
51 | 51 | { |
52 | - if (! array_key_exists($uploadName, $this->registeredUploaders) || ! in_array($uploader, $this->registeredUploaders[$uploadName])) { |
|
52 | + if (!array_key_exists($uploadName, $this->registeredUploaders) || !in_array($uploader, $this->registeredUploaders[$uploadName])) { |
|
53 | 53 | $this->registeredUploaders[$uploadName][] = $uploader; |
54 | 54 | } |
55 | 55 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | public function getRegisteredUploadNames(string $uploadName) |
72 | 72 | { |
73 | - return array_map(function ($uploader) { |
|
73 | + return array_map(function($uploader) { |
|
74 | 74 | return $uploader->getName(); |
75 | 75 | }, $this->getRegisteredUploadersFor($uploadName)); |
76 | 76 | } |
@@ -48,7 +48,7 @@ |
||
48 | 48 | if (isset($attributes['subfields'])) { |
49 | 49 | foreach ($attributes['subfields'] as $subfield) { |
50 | 50 | if (isset($subfield[$macro])) { |
51 | - $config = ! is_array($subfield[$macro]) ? [] : $subfield[$macro]; |
|
51 | + $config = !is_array($subfield[$macro]) ? [] : $subfield[$macro]; |
|
52 | 52 | $macroable->{$macro}($config, $subfield); |
53 | 53 | } |
54 | 54 | } |