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('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 | |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | }); |
44 | 44 | } |
45 | 45 | |
46 | -if (! CrudField::hasMacro('withFiles')) { |
|
47 | - CrudField::macro('withFiles', function ($uploadDefinition = [], $subfield = null) { |
|
46 | +if (!CrudField::hasMacro('withFiles')) { |
|
47 | + CrudField::macro('withFiles', function($uploadDefinition = [], $subfield = null) { |
|
48 | 48 | /** @var CrudField|CrudColumn $this */ |
49 | 49 | RegisterUploadEvents::handle($this, $uploadDefinition, 'withFiles', $subfield); |
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 = ''; |
@@ -46,7 +46,7 @@ |
||
46 | 46 | if (isset($attributes['subfields'])) { |
47 | 47 | foreach ($attributes['subfields'] as $subfield) { |
48 | 48 | if (isset($subfield[$macro])) { |
49 | - $config = ! is_array($subfield[$macro]) ? [] : $subfield[$macro]; |
|
49 | + $config = !is_array($subfield[$macro]) ? [] : $subfield[$macro]; |
|
50 | 50 | $this->{$macro}($config, $subfield); |
51 | 51 | } |
52 | 52 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | $value = $value ?? CRUD::getRequest()->get($this->getName()); |
15 | 15 | $previousImage = $entry->getOriginal($this->getName()); |
16 | 16 | |
17 | - if (! $value && $previousImage) { |
|
17 | + if (!$value && $previousImage) { |
|
18 | 18 | Storage::disk($this->getDisk())->delete($previousImage); |
19 | 19 | |
20 | 20 | return null; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | { |
191 | 191 | $value = $entry->{$this->name}; |
192 | 192 | |
193 | - if ($this->isMultiple && ! isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
193 | + if ($this->isMultiple && !isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
194 | 194 | $entry->{$this->name} = json_decode($value, true); |
195 | 195 | |
196 | 196 | return $entry; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | public function deleteUploadedFile(Model $entry) |
211 | 211 | { |
212 | 212 | if ($this->deleteWhenEntryIsDeleted) { |
213 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
213 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
214 | 214 | $this->performFileDeletion($entry); |
215 | 215 | |
216 | 216 | return; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | if ($this->isMultiple) { |
236 | 236 | // ensure we have an array of values when field is not casted in model. |
237 | - if (! isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
237 | + if (!isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
238 | 238 | $values = json_decode($values, true); |
239 | 239 | } |
240 | 240 | foreach ($values as $value) { |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | private function performFileDeletion($entry) |
259 | 259 | { |
260 | - if ($this->isRelationship || ! $this->isRepeatable) { |
|
260 | + if ($this->isRelationship || !$this->isRepeatable) { |
|
261 | 261 | $this->deleteFiles($entry); |
262 | 262 | |
263 | 263 | return; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @param array $definition |
274 | 274 | * @return self |
275 | 275 | */ |
276 | - public static function for(array $crudObject, array $definition) |
|
276 | + public static function for (array $crudObject, array $definition) |
|
277 | 277 | { |
278 | 278 | return new static($crudObject, $definition); |
279 | 279 | } |
@@ -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 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | $value = $value ?? CRUD::getRequest()->file($this->getName()); |
21 | 21 | $previousFiles = $entry->getOriginal($this->getName()) ?? []; |
22 | 22 | |
23 | - if (! is_array($previousFiles) && is_string($previousFiles)) { |
|
23 | + if (!is_array($previousFiles) && is_string($previousFiles)) { |
|
24 | 24 | $previousFiles = json_decode($previousFiles, true); |
25 | 25 | } |
26 | 26 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | if (in_array($previousFile, $filesToDelete)) { |
30 | 30 | Storage::disk($this->getDisk())->delete($previousFile); |
31 | 31 | |
32 | - $previousFiles = Arr::where($previousFiles, function ($value, $key) use ($previousFile) { |
|
32 | + $previousFiles = Arr::where($previousFiles, function($value, $key) use ($previousFile) { |
|
33 | 33 | return $value != $previousFile; |
34 | 34 | }); |
35 | 35 | } |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | private string $crudObjectType; |
15 | 15 | |
16 | 16 | public function __construct( |
17 | - private readonly CrudField|CrudColumn $crudObject, |
|
17 | + private readonly CrudField | CrudColumn $crudObject, |
|
18 | 18 | private readonly array $uploaderConfiguration, |
19 | 19 | private readonly string $macro |
20 | 20 | ) { |
21 | 21 | $this->crudObjectType = is_a($crudObject, CrudField::class) ? 'field' : (is_a($crudObject, CrudColumn::class) ? 'column' : null); |
22 | 22 | |
23 | - if (! $this->crudObjectType) { |
|
23 | + if (!$this->crudObjectType) { |
|
24 | 24 | abort(500, 'Upload handlers only work for CrudField and CrudColumn classes.'); |
25 | 25 | } |
26 | 26 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | if ($this->crudObjectType === 'field') { |
60 | - $model::saving(function ($entry) use ($uploader) { |
|
60 | + $model::saving(function($entry) use ($uploader) { |
|
61 | 61 | $updatedCountKey = 'uploaded_'.($uploader->getRepeatableContainerName() ?? $uploader->getName()).'_count'; |
62 | 62 | |
63 | 63 | CRUD::set($updatedCountKey, CRUD::get($updatedCountKey) ?? 0); |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | }); |
69 | 69 | } |
70 | 70 | |
71 | - $model::retrieved(function ($entry) use ($uploader) { |
|
71 | + $model::retrieved(function($entry) use ($uploader) { |
|
72 | 72 | $entry = $uploader->retrieveUploadedFile($entry); |
73 | 73 | }); |
74 | 74 | |
75 | - $model::deleting(function ($entry) use ($uploader) { |
|
75 | + $model::deleting(function($entry) use ($uploader) { |
|
76 | 76 | $uploader->deleteUploadedFile($entry); |
77 | 77 | }); |
78 | 78 | |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * @param array|null $subfield |
86 | 86 | * @return void |
87 | 87 | */ |
88 | - public function registerEvents(array|null $subfield = []) |
|
88 | + public function registerEvents(array | null $subfield = []) |
|
89 | 89 | { |
90 | - if (! empty($subfield)) { |
|
90 | + if (!empty($subfield)) { |
|
91 | 91 | $this->registerSubfieldEvent($subfield); |
92 | 92 | |
93 | 93 | return; |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | |
130 | 130 | // for subfields, we only register one event so that we have access to the repeatable container name. |
131 | 131 | // all the uploaders for a given container are stored in the UploadersRepository. |
132 | - if (! app('UploadersRepository')->hasRepeatableUploadersFor($uploader->getRepeatableContainerName())) { |
|
132 | + if (!app('UploadersRepository')->hasRepeatableUploadersFor($uploader->getRepeatableContainerName())) { |
|
133 | 133 | $this->setupModelEvents($model, $uploader); |
134 | 134 | } |
135 | 135 | |
136 | 136 | $subfields = collect($this->crudObject->getAttributes()['subfields']); |
137 | - $subfields = $subfields->map(function ($item) use ($subfield, $uploader) { |
|
137 | + $subfields = $subfields->map(function($item) use ($subfield, $uploader) { |
|
138 | 138 | if ($item['name'] === $subfield['name']) { |
139 | 139 | $item['upload'] = true; |
140 | 140 | $item['disk'] = $uploader->getDisk(); |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | $customUploader = isset($uploaderConfiguration['uploader']) && class_exists($uploaderConfiguration['uploader']); |
173 | 173 | |
174 | 174 | if ($customUploader) { |
175 | - return $uploaderConfiguration['uploader']::for($crudObject, $uploaderConfiguration); |
|
175 | + return $uploaderConfiguration['uploader']::for ($crudObject, $uploaderConfiguration); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | $uploader = app('UploadersRepository')->hasUploadFor($crudObject['type'], $this->macro); |
179 | 179 | |
180 | 180 | if ($uploader) { |
181 | - return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for($crudObject, $uploaderConfiguration); |
|
181 | + return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for ($crudObject, $uploaderConfiguration); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | throw new Exception('Undefined upload type for '.$this->crudObjectType.' type: '.$crudObject['type']); |
@@ -37,7 +37,7 @@ |
||
37 | 37 | * @param array $configuration |
38 | 38 | * @return void |
39 | 39 | */ |
40 | - public static function for(array $field, array $configuration); |
|
40 | + public static function for (array $field, array $configuration); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Called to upload a single file |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->repeatableContainerName) as $uploader) { |
115 | 115 | $uploadedValues = $uploader->uploadRepeatableFile($entry, $value->pluck($uploader->getName())->toArray()); |
116 | 116 | |
117 | - $value = $value->map(function ($item, $key) use ($uploadedValues, $uploader) { |
|
117 | + $value = $value->map(function($item, $key) use ($uploadedValues, $uploader) { |
|
118 | 118 | $item[$uploader->getName()] = $uploadedValues[$key] ?? null; |
119 | 119 | |
120 | 120 | return $item; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | protected function getPreviousRepeatableValues(Model $entry) |
134 | 134 | { |
135 | 135 | $previousValues = json_decode($entry->getOriginal($this->repeatableContainerName), true); |
136 | - if (! empty($previousValues)) { |
|
136 | + if (!empty($previousValues)) { |
|
137 | 137 | $previousValues = array_column($previousValues, $this->getName()); |
138 | 138 | } |
139 | 139 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | $items = CRUD::getRequest()->input('_order_'.$this->repeatableContainerName) ?? []; |
152 | 152 | |
153 | - array_walk($items, function (&$key, $value) { |
|
153 | + array_walk($items, function(&$key, $value) { |
|
154 | 154 | $requestValue = $key[$this->getName()] ?? null; |
155 | 155 | $key = $this->isMultiple ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
156 | 156 | }); |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | |
190 | 190 | $repeatableValues = collect($entry->{$this->getName()}); |
191 | 191 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->repeatableContainerName) as $upload) { |
192 | - if (! $upload->shouldDeleteFiles()) { |
|
192 | + if (!$upload->shouldDeleteFiles()) { |
|
193 | 193 | continue; |
194 | 194 | } |
195 | 195 | $values = $repeatableValues->pluck($upload->getName())->toArray(); |
196 | 196 | foreach ($values as $value) { |
197 | - if (! $value) { |
|
197 | + if (!$value) { |
|
198 | 198 | continue; |
199 | 199 | } |
200 | 200 | if (is_array($value)) { |
@@ -31,11 +31,11 @@ |
||
31 | 31 | { |
32 | 32 | $fileGeneratorClass = $fileNameGenerator ?? config('backpack.crud.file_name_generator'); |
33 | 33 | |
34 | - if (! class_exists($fileGeneratorClass)) { |
|
34 | + if (!class_exists($fileGeneratorClass)) { |
|
35 | 35 | throw new \Exception("The file name generator class [{$fileGeneratorClass}] does not exist."); |
36 | 36 | } |
37 | 37 | |
38 | - if (! class_implements($fileGeneratorClass, FileNameGeneratorInterface::class)) { |
|
38 | + if (!class_implements($fileGeneratorClass, FileNameGeneratorInterface::class)) { |
|
39 | 39 | throw new \Exception("The file name generator class [{$fileGeneratorClass}] must implement the [".FileNameGeneratorInterface::class.'] interface.'); |
40 | 40 | } |
41 | 41 |