We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -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 { |
@@ -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 |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public function uploads(...$uploads): self; |
10 | 10 | |
11 | - public static function for(array $field); |
|
11 | + public static function for (array $field); |
|
12 | 12 | |
13 | 13 | public function processFileUpload(Model $entry); |
14 | 14 |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | { |
193 | 193 | $value = $entry->{$this->name}; |
194 | 194 | |
195 | - if ($this->isMultiple && ! isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
195 | + if ($this->isMultiple && !isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
196 | 196 | $entry->{$this->name} = json_decode($value, true); |
197 | 197 | } else { |
198 | 198 | $entry->{$this->name} = Str::after($value, $this->path); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $values = $entry->{$this->name}; |
213 | 213 | |
214 | 214 | if ($this->isMultiple) { |
215 | - if (! isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
215 | + if (!isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
216 | 216 | $values = json_decode($values, true); |
217 | 217 | } |
218 | 218 | } else { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param array $definition |
232 | 232 | * @return self |
233 | 233 | */ |
234 | - public static function for(array $crudObject, array $definition) |
|
234 | + public static function for (array $crudObject, array $definition) |
|
235 | 235 | { |
236 | 236 | return new static($crudObject, $definition); |
237 | 237 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | { |
295 | 295 | $items = CRUD::getRequest()->input('_order_'.$this->repeatableContainerName) ?? []; |
296 | 296 | |
297 | - array_walk($items, function (&$key, $value) { |
|
297 | + array_walk($items, function(&$key, $value) { |
|
298 | 298 | $requestValue = $key[$this->name] ?? null; |
299 | 299 | $key = $this->isMultiple ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
300 | 300 | }); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | protected function getPreviousRepeatableValues(Model $entry) |
322 | 322 | { |
323 | 323 | $previousValues = json_decode($entry->getOriginal($this->repeatableContainerName), true); |
324 | - if (! empty($previousValues)) { |
|
324 | + if (!empty($previousValues)) { |
|
325 | 325 | $previousValues = array_column($previousValues, $this->name); |
326 | 326 | } |
327 | 327 |
@@ -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 | } |
@@ -66,24 +66,24 @@ discard block |
||
66 | 66 | include_once __DIR__.'/macros.php'; |
67 | 67 | |
68 | 68 | // Bind the CrudPanel object to Laravel's service container |
69 | - $this->app->scoped('crud', function ($app) { |
|
69 | + $this->app->scoped('crud', function($app) { |
|
70 | 70 | return new CrudPanel(); |
71 | 71 | }); |
72 | 72 | |
73 | - $this->app->scoped('DatabaseSchema', function ($app) { |
|
73 | + $this->app->scoped('DatabaseSchema', function($app) { |
|
74 | 74 | return new DatabaseSchema(); |
75 | 75 | }); |
76 | 76 | |
77 | - $this->app->singleton('BackpackViewNamespaces', function ($app) { |
|
77 | + $this->app->singleton('BackpackViewNamespaces', function($app) { |
|
78 | 78 | return new ViewNamespaces(); |
79 | 79 | }); |
80 | 80 | |
81 | 81 | // Bind the widgets collection object to Laravel's service container |
82 | - $this->app->singleton('widgets', function ($app) { |
|
82 | + $this->app->singleton('widgets', function($app) { |
|
83 | 83 | return new Collection(); |
84 | 84 | }); |
85 | 85 | |
86 | - $this->app->scoped('UploadersRepository', function ($app) { |
|
86 | + $this->app->scoped('UploadersRepository', function($app) { |
|
87 | 87 | return new UploadersRepository(); |
88 | 88 | }); |
89 | 89 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $middleware_key = config('backpack.base.middleware_key'); |
100 | 100 | $middleware_class = config('backpack.base.middleware_class'); |
101 | 101 | |
102 | - if (! is_array($middleware_class)) { |
|
102 | + if (!is_array($middleware_class)) { |
|
103 | 103 | $router->pushMiddlewareToGroup($middleware_key, $middleware_class); |
104 | 104 | |
105 | 105 | return; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $operationConfigs = scandir(__DIR__.'/config/backpack/operations/'); |
216 | 216 | $operationConfigs = array_diff($operationConfigs, ['.', '..']); |
217 | 217 | |
218 | - if (! count($operationConfigs)) { |
|
218 | + if (!count($operationConfigs)) { |
|
219 | 219 | return; |
220 | 220 | } |
221 | 221 |
@@ -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 = []) { |
|
37 | +if (!CrudColumn::hasMacro('withFiles')) { |
|
38 | + CrudColumn::macro('withFiles', function($uploadDefinition = []) { |
|
39 | 39 | /** @var CrudField|CrudColumn $this */ |
40 | 40 | $uploadDefinition['uploadersGroup'] = 'withFiles'; |
41 | 41 | RegisterUploadEvents::handle($this, $uploadDefinition); |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | }); |
45 | 45 | } |
46 | 46 | |
47 | -if (! CrudField::hasMacro('withFiles')) { |
|
48 | - CrudField::macro('withFiles', function ($uploadDefinition = []) { |
|
47 | +if (!CrudField::hasMacro('withFiles')) { |
|
48 | + CrudField::macro('withFiles', function($uploadDefinition = []) { |
|
49 | 49 | /** @var CrudField|CrudColumn $this */ |
50 | 50 | $uploadDefinition['uploadersGroup'] = 'withFiles'; |
51 | 51 | RegisterUploadEvents::handle($this, $uploadDefinition); |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * |
61 | 61 | * It will go to the given CrudController and get the setupRoutes() method on it. |
62 | 62 | */ |
63 | -if (! Route::hasMacro('crud')) { |
|
64 | - Route::macro('crud', function ($name, $controller) { |
|
63 | +if (!Route::hasMacro('crud')) { |
|
64 | + Route::macro('crud', function($name, $controller) { |
|
65 | 65 | // put together the route name prefix, |
66 | 66 | // as passed to the Route::group() statements |
67 | 67 | $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 | |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | |
38 | 38 | $crudObjectType = is_a($crudObject, CrudField::class) ? 'field' : (is_a($crudObject, CrudColumn::class) ? 'column' : null); |
39 | 39 | |
40 | - if (! $crudObjectType) { |
|
40 | + if (!$crudObjectType) { |
|
41 | 41 | abort(500, 'Upload handlers only work for CrudField and CrudColumn classes.'); |
42 | 42 | } |
43 | 43 | |
44 | 44 | $attributes['crudObjectType'] = $crudObjectType; |
45 | 45 | |
46 | - if (! isset($attributes['subfields'])) { |
|
46 | + if (!isset($attributes['subfields'])) { |
|
47 | 47 | $uploaderType = $instance->getUploader($attributes, $uploadDefinition); |
48 | 48 | $instance->setupModelEvents($attributes['entryClass'], $uploaderType); |
49 | 49 | self::setupUploadConfigsInCrudObject($crudObject, $uploaderType); |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | * @param UploaderInterface|RepeatableUploaderInterface $uploader |
63 | 63 | * @return void |
64 | 64 | */ |
65 | - private function setupModelEvents(string $model, UploaderInterface|RepeatableUploaderInterface $uploader): void |
|
65 | + private function setupModelEvents(string $model, UploaderInterface | RepeatableUploaderInterface $uploader): void |
|
66 | 66 | { |
67 | 67 | if (app('UploadersRepository')->isUploadHandled($uploader->getName())) { |
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | 71 | if ($uploader->getCrudObjectType() === 'field') { |
72 | - $model::saving(function ($entry) use ($uploader) { |
|
72 | + $model::saving(function($entry) use ($uploader) { |
|
73 | 73 | $updatedCountKey = 'uploaded_'.$uploader->getName().'_count'; |
74 | 74 | |
75 | 75 | CRUD::set($updatedCountKey, CRUD::get($updatedCountKey) ?? 0); |
@@ -80,18 +80,18 @@ discard block |
||
80 | 80 | }); |
81 | 81 | } |
82 | 82 | |
83 | - $model::retrieved(function ($entry) use ($uploader) { |
|
83 | + $model::retrieved(function($entry) use ($uploader) { |
|
84 | 84 | $entry = $uploader->retrieveUploadedFile($entry); |
85 | 85 | }); |
86 | 86 | |
87 | - $model::deleting(function ($entry) use ($uploader) { |
|
87 | + $model::deleting(function($entry) use ($uploader) { |
|
88 | 88 | if (is_a($uploader, RepeatableUploaderInterface::class)) { |
89 | 89 | $uploader->deleteUploadedFile($entry); |
90 | 90 | |
91 | 91 | return; |
92 | 92 | } |
93 | 93 | if ($uploader->deleteWhenEntryIsDeleted) { |
94 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
94 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
95 | 95 | $uploader->deleteUploadedFile($entry); |
96 | 96 | } else { |
97 | 97 | if ($entry->forceDeleting === true) { |
@@ -125,8 +125,7 @@ discard block |
||
125 | 125 | $subfielduploadDefinition = $subfield['withUploads'] ?? $subfield['withMedia']; |
126 | 126 | |
127 | 127 | $subfielduploadDefinition = is_array($subfielduploadDefinition) ? |
128 | - array_merge($uploadDefinition, $subfielduploadDefinition) : |
|
129 | - $uploadDefinition; |
|
128 | + array_merge($uploadDefinition, $subfielduploadDefinition) : $uploadDefinition; |
|
130 | 129 | |
131 | 130 | $uploaderType = $this->getUploader($subfield, $subfielduploadDefinition); |
132 | 131 | |
@@ -135,7 +134,7 @@ discard block |
||
135 | 134 | } |
136 | 135 | |
137 | 136 | foreach ($repeatableDefinitions as $model => $uploaderTypes) { |
138 | - $repeatableDefinition = app('UploadersRepository')->getUploadFor('repeatable', $uploadDefinition['uploadersGroup'] ?? null)::for($crudObject)->uploads(...$uploaderTypes); |
|
137 | + $repeatableDefinition = app('UploadersRepository')->getUploadFor('repeatable', $uploadDefinition['uploadersGroup'] ?? null)::for ($crudObject)->uploads(...$uploaderTypes); |
|
139 | 138 | $this->setupModelEvents($model, $repeatableDefinition); |
140 | 139 | } |
141 | 140 | } |
@@ -157,13 +156,13 @@ discard block |
||
157 | 156 | private function getUploader(array $crudObject, array $uploadDefinition) |
158 | 157 | { |
159 | 158 | if (isset($uploadDefinition['uploaderType'])) { |
160 | - return $uploadDefinition['uploaderType']::for($crudObject, $uploadDefinition); |
|
159 | + return $uploadDefinition['uploaderType']::for ($crudObject, $uploadDefinition); |
|
161 | 160 | } |
162 | 161 | |
163 | 162 | $uploaders = $uploadDefinition['uploadersGroup'] ?? null; |
164 | 163 | |
165 | 164 | if (app('UploadStore')->hasUploadFor($crudObject['type'], $uploaders)) { |
166 | - return app('UploadStore')->getUploadFor($crudObject['type'], $uploaders)::for($crudObject, $uploadDefinition); |
|
165 | + return app('UploadStore')->getUploadFor($crudObject['type'], $uploaders)::for ($crudObject, $uploadDefinition); |
|
167 | 166 | } |
168 | 167 | |
169 | 168 | throw new Exception('Undefined upload type for '.$crudObject['crudObjectType'].' type: '.$crudObject['type']); |
@@ -176,7 +175,7 @@ discard block |
||
176 | 175 | * @param UploaderInterface $uploader |
177 | 176 | * @return void |
178 | 177 | */ |
179 | - private static function setupUploadConfigsInCrudObject(CrudField|CrudColumn $crudObject, UploaderInterface $uploader) |
|
178 | + private static function setupUploadConfigsInCrudObject(CrudField | CrudColumn $crudObject, UploaderInterface $uploader) |
|
180 | 179 | { |
181 | 180 | $crudObject->upload(true)->disk($uploader->disk)->prefix($uploader->path); |
182 | 181 | } |
@@ -135,7 +135,9 @@ |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | foreach ($repeatableDefinitions as $model => $uploaderTypes) { |
138 | - $repeatableDefinition = app('UploadersRepository')->getUploadFor('repeatable', $uploadDefinition['uploadersGroup'] ?? null)::for($crudObject)->uploads(...$uploaderTypes); |
|
138 | + $repeatableDefinition = app('UploadersRepository')->getUploadFor('repeatable', $uploadDefinition['uploadersGroup'] ?? null)::for($crudObject) { |
|
139 | + ->uploads(...$uploaderTypes); |
|
140 | + } |
|
139 | 141 | $this->setupModelEvents($model, $repeatableDefinition); |
140 | 142 | } |
141 | 143 | } |