We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -47,8 +47,8 @@ |
||
47 | 47 | ->filter(fn ($item) => isset($item[$macro])); |
48 | 48 | |
49 | 49 | $subfieldsWithMacros->each( |
50 | - function ($item) use ($subfieldsWithMacros, $macro) { |
|
51 | - $config = ! is_array($item[$macro]) ? [] : $item[$macro]; |
|
50 | + function($item) use ($subfieldsWithMacros, $macro) { |
|
51 | + $config = !is_array($item[$macro]) ? [] : $item[$macro]; |
|
52 | 52 | if ($subfieldsWithMacros->last() === $item) { |
53 | 53 | $this->{$macro}($config, $item); |
54 | 54 | } else { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function setValidation($classOrRulesArray = false, $messages = [], $attributes = []) |
68 | 68 | { |
69 | - if (! $classOrRulesArray) { |
|
69 | + if (!$classOrRulesArray) { |
|
70 | 70 | $this->setValidationFromFields(); |
71 | 71 | } elseif (is_array($classOrRulesArray)) { |
72 | 72 | $this->setValidationFromArray($classOrRulesArray, $messages, $attributes); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | return $this->checkRequestValidity($extendedRules, $extendedMessages, $extendedAttributes, $formRequest); |
148 | 148 | } |
149 | 149 | |
150 | - return ! empty($rules) ? $this->checkRequestValidity($rules, $messages, $attributes) : $this->getRequest(); |
|
150 | + return !empty($rules) ? $this->checkRequestValidity($rules, $messages, $attributes) : $this->getRequest(); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | if (is_string($validationRules)) { |
196 | 196 | $validationRules = explode('|', $validationRules); |
197 | 197 | } |
198 | - if (! is_array($validationRules)) { |
|
198 | + if (!is_array($validationRules)) { |
|
199 | 199 | $validationRules = [$validationRules]; |
200 | 200 | } |
201 | 201 | foreach ($validationRules as $rule) { |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function isRequired($inputKey) |
240 | 240 | { |
241 | - if (! $this->hasOperationSetting('requiredFields')) { |
|
241 | + if (!$this->hasOperationSetting('requiredFields')) { |
|
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | { |
260 | 260 | [$rules, $messages, $attributes] = $this->getValidationDataFromField($field, $parent); |
261 | 261 | |
262 | - if (! empty($rules)) { |
|
262 | + if (!empty($rules)) { |
|
263 | 263 | $this->setValidation($rules, $messages, $attributes); |
264 | 264 | } |
265 | 265 | } |
@@ -274,10 +274,10 @@ discard block |
||
274 | 274 | { |
275 | 275 | $messages = []; |
276 | 276 | collect($fields) |
277 | - ->filter(function ($value, $key) { |
|
277 | + ->filter(function($value, $key) { |
|
278 | 278 | // only keep fields where 'validationMessages' OR there are subfields |
279 | 279 | return array_key_exists('validationMessages', $value) || array_key_exists('subfields', $value); |
280 | - })->each(function ($item, $key) use (&$messages) { |
|
280 | + })->each(function($item, $key) use (&$messages) { |
|
281 | 281 | if (isset($item['validationMessages'])) { |
282 | 282 | foreach ($item['validationMessages'] as $rule => $message) { |
283 | 283 | $messages[$key.'.'.$rule] = $message; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | // add messages from subfields |
287 | 287 | if (array_key_exists('subfields', $item)) { |
288 | - $subfieldsWithValidationMessages = array_filter($item['subfields'], function ($subfield) { |
|
288 | + $subfieldsWithValidationMessages = array_filter($item['subfields'], function($subfield) { |
|
289 | 289 | return array_key_exists('validationRules', $subfield); |
290 | 290 | }); |
291 | 291 | |
@@ -310,16 +310,16 @@ discard block |
||
310 | 310 | { |
311 | 311 | $attributes = []; |
312 | 312 | collect($fields) |
313 | - ->filter(function ($value, $key) { |
|
313 | + ->filter(function($value, $key) { |
|
314 | 314 | // only keep fields where 'validationAttribute' exists OR there are subfields |
315 | 315 | return array_key_exists('validationAttribute', $value) || array_key_exists('subfields', $value); |
316 | - })->each(function ($item, $key) use (&$attributes) { |
|
316 | + })->each(function($item, $key) use (&$attributes) { |
|
317 | 317 | if (isset($item['validationAttribute'])) { |
318 | 318 | $attributes[$key] = $item['validationAttribute']; |
319 | 319 | } |
320 | 320 | // add attributes from subfields |
321 | 321 | if (array_key_exists('subfields', $item)) { |
322 | - $subfieldsWithValidationAttribute = array_filter($item['subfields'], function ($subfield) { |
|
322 | + $subfieldsWithValidationAttribute = array_filter($item['subfields'], function($subfield) { |
|
323 | 323 | return array_key_exists('validationAttribute', $subfield); |
324 | 324 | }); |
325 | 325 | |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | private function getValidationRulesFromFieldsAndSubfields($fields) |
342 | 342 | { |
343 | 343 | $rules = collect($fields) |
344 | - ->filter(function ($value, $key) { |
|
344 | + ->filter(function($value, $key) { |
|
345 | 345 | // only keep fields where 'validationRules' OR there are subfields |
346 | 346 | return array_key_exists('validationRules', $value) || array_key_exists('subfields', $value); |
347 | - })->map(function ($item, $key) { |
|
347 | + })->map(function($item, $key) { |
|
348 | 348 | $validationRules = []; |
349 | 349 | // only keep the rules, not the entire field definition |
350 | 350 | if (isset($item['validationRules'])) { |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | } |
353 | 353 | // add validation rules for subfields |
354 | 354 | if (array_key_exists('subfields', $item)) { |
355 | - $subfieldsWithValidation = array_filter($item['subfields'], function ($subfield) { |
|
355 | + $subfieldsWithValidation = array_filter($item['subfields'], function($subfield) { |
|
356 | 356 | return array_key_exists('validationRules', $subfield); |
357 | 357 | }); |
358 | 358 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $otherButtons = collect([]); |
25 | 25 | |
26 | 26 | // we get the buttons that belong to the specified stack |
27 | - $stackButtons = $this->buttons()->reject(function ($item) use ($stack, $otherButtons) { |
|
27 | + $stackButtons = $this->buttons()->reject(function($item) use ($stack, $otherButtons) { |
|
28 | 28 | if ($item->stack != $stack) { |
29 | 29 | // if the button does not belong to this stack we just add it for merging later |
30 | 30 | $otherButtons->push($item); |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | }); |
37 | 37 | |
38 | 38 | // we parse the ordered buttons |
39 | - collect($order)->each(function ($btnKey) use ($newButtons, $stackButtons) { |
|
40 | - if (! $button = $stackButtons->where('name', $btnKey)->first()) { |
|
39 | + collect($order)->each(function($btnKey) use ($newButtons, $stackButtons) { |
|
40 | + if (!$button = $stackButtons->where('name', $btnKey)->first()) { |
|
41 | 41 | abort(500, 'Button name [«'.$btnKey.'»] not found.'); |
42 | 42 | } |
43 | 43 | $newButtons->push($button); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | // we add the remaining buttons to the end of the ordered ones |
48 | 48 | if (count($newButtons) < count($stackButtons)) { |
49 | 49 | foreach ($stackButtons as $button) { |
50 | - if (! $newButtons->where('name', $button->name)->first()) { |
|
50 | + if (!$newButtons->where('name', $button->name)->first()) { |
|
51 | 51 | $newButtons->push($button); |
52 | 52 | } |
53 | 53 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | $button = $this->buttons()->firstWhere('name', $name); |
118 | 118 | |
119 | - if (! $button) { |
|
119 | + if (!$button) { |
|
120 | 120 | abort(500, 'CRUD Button "'.$name.'" not found. Please ensure the button exists before you modify it.'); |
121 | 121 | } |
122 | 122 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function removeButton($name, $stack = null) |
139 | 139 | { |
140 | - $this->setOperationSetting('buttons', $this->buttons()->reject(function ($button) use ($name, $stack) { |
|
140 | + $this->setOperationSetting('buttons', $this->buttons()->reject(function($button) use ($name, $stack) { |
|
141 | 141 | return $stack == null ? $button->name == $name : ($button->stack == $stack) && ($button->name == $name); |
142 | 142 | })); |
143 | 143 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function removeButtons($names, $stack = null) |
150 | 150 | { |
151 | - if (! empty($names)) { |
|
151 | + if (!empty($names)) { |
|
152 | 152 | foreach ($names as $name) { |
153 | 153 | $this->removeButton($name, $stack); |
154 | 154 | } |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | |
163 | 163 | public function removeAllButtonsFromStack($stack) |
164 | 164 | { |
165 | - $this->setOperationSetting('buttons', $this->buttons()->reject(function ($button) use ($stack) { |
|
165 | + $this->setOperationSetting('buttons', $this->buttons()->reject(function($button) use ($stack) { |
|
166 | 166 | return $button->stack == $stack; |
167 | 167 | })); |
168 | 168 | } |
169 | 169 | |
170 | 170 | public function removeButtonFromStack($name, $stack) |
171 | 171 | { |
172 | - $this->setOperationSetting('buttons', $this->buttons()->reject(function ($button) use ($name, $stack) { |
|
172 | + $this->setOperationSetting('buttons', $this->buttons()->reject(function($button) use ($name, $stack) { |
|
173 | 173 | return $button->name == $name && $button->stack == $stack; |
174 | 174 | })); |
175 | 175 | } |
@@ -190,15 +190,15 @@ discard block |
||
190 | 190 | $destinationKey = $this->getButtonKey($destination); |
191 | 191 | $newDestinationKey = ($where == 'before' ? $destinationKey : $destinationKey + 1); |
192 | 192 | |
193 | - $newButtons = $this->buttons()->filter(function ($value, $key) use ($target) { |
|
193 | + $newButtons = $this->buttons()->filter(function($value, $key) use ($target) { |
|
194 | 194 | return $value->name != $target; |
195 | 195 | }); |
196 | 196 | |
197 | - if (! $targetButton) { |
|
197 | + if (!$targetButton) { |
|
198 | 198 | return; |
199 | 199 | } |
200 | 200 | |
201 | - if (! $destinationButton) { |
|
201 | + if (!$destinationButton) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | $newButtons = $firstSlice->push($targetButton); |
209 | 209 | |
210 | - $lastSlice->each(function ($item, $key) use ($newButtons) { |
|
210 | + $lastSlice->each(function($item, $key) use ($newButtons) { |
|
211 | 211 | $newButtons->push($item); |
212 | 212 | }); |
213 | 213 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | /** |
267 | 267 | * Add a new button to the current CRUD operation. |
268 | 268 | */ |
269 | - public function button(string|array $nameOrAttributes): CrudButton |
|
269 | + public function button(string | array $nameOrAttributes): CrudButton |
|
270 | 270 | { |
271 | 271 | return new CrudButton($nameOrAttributes); |
272 | 272 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | private bool $deleteWhenEntryIsDeleted = true; |
27 | 27 | |
28 | - private bool|string $attachedToFakeField = false; |
|
28 | + private bool | string $attachedToFakeField = false; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Cloud disks have the ability to generate temporary URLs to files, should we do it? |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | /******************************* |
58 | 58 | * Static methods |
59 | 59 | *******************************/ |
60 | - public static function for(array $crudObject, array $definition): UploaderInterface |
|
60 | + public static function for (array $crudObject, array $definition): UploaderInterface |
|
61 | 61 | { |
62 | 62 | return new static($crudObject, $definition); |
63 | 63 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public function deleteUploadedFiles(Model $entry): void |
99 | 99 | { |
100 | 100 | if ($this->deleteWhenEntryIsDeleted) { |
101 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
101 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
102 | 102 | $this->performFileDeletion($entry); |
103 | 103 | |
104 | 104 | return; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | public function getPreviousFiles(Model $entry): mixed |
161 | 161 | { |
162 | - if (! $this->attachedToFakeField) { |
|
162 | + if (!$this->attachedToFakeField) { |
|
163 | 163 | return $entry->getOriginal($this->getName()); |
164 | 164 | } |
165 | 165 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $value = $entry->{$this->name}; |
199 | 199 | |
200 | 200 | if ($this->handleMultipleFiles) { |
201 | - if (! isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
201 | + if (!isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
202 | 202 | $entry->{$this->name} = json_decode($value, true); |
203 | 203 | } |
204 | 204 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | if ($this->handleMultipleFiles) { |
228 | 228 | // ensure we have an array of values when field is not casted in model. |
229 | - if (! isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
229 | + if (!isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
230 | 230 | $values = json_decode($values, true); |
231 | 231 | } |
232 | 232 | foreach ($values as $value) { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | private function performFileDeletion(Model $entry) |
244 | 244 | { |
245 | - if ($this->isRelationship || ! $this->handleRepeatableFiles) { |
|
245 | + if ($this->isRelationship || !$this->handleRepeatableFiles) { |
|
246 | 246 | $this->deleteFiles($entry); |
247 | 247 | |
248 | 248 | return; |
@@ -13,18 +13,18 @@ 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 | } |
26 | 26 | |
27 | - public static function handle(CrudField|CrudColumn $crudObject, array $uploaderConfiguration, string $macro, ?array $subfield = null, ?bool $registerModelEvents = true): void |
|
27 | + public static function handle(CrudField | CrudColumn $crudObject, array $uploaderConfiguration, string $macro, ?array $subfield = null, ?bool $registerModelEvents = true): void |
|
28 | 28 | { |
29 | 29 | $instance = new self($crudObject, $uploaderConfiguration, $macro); |
30 | 30 | |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | /******************************* |
35 | 35 | * Private methods - implementation |
36 | 36 | *******************************/ |
37 | - private function registerEvents(array|null $subfield = [], ?bool $registerModelEvents = true): void |
|
37 | + private function registerEvents(array | null $subfield = [], ?bool $registerModelEvents = true): void |
|
38 | 38 | { |
39 | - if (! empty($subfield)) { |
|
39 | + if (!empty($subfield)) { |
|
40 | 40 | $this->registerSubfieldEvent($subfield, $registerModelEvents); |
41 | 41 | |
42 | 42 | return; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | $subfields = collect($this->crudObject->getAttributes()['subfields']); |
78 | - $subfields = $subfields->map(function ($item) use ($subfield, $uploader) { |
|
78 | + $subfields = $subfields->map(function($item) use ($subfield, $uploader) { |
|
79 | 79 | if ($item['name'] === $subfield['name']) { |
80 | 80 | $item['upload'] = true; |
81 | 81 | $item['disk'] = $uploader->getDisk(); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | if ($this->crudObjectType === 'field') { |
108 | - $model::saving(function ($entry) use ($uploader) { |
|
108 | + $model::saving(function($entry) use ($uploader) { |
|
109 | 109 | $updatedCountKey = 'uploaded_'.($uploader->getRepeatableContainerName() ?? $uploader->getName()).'_count'; |
110 | 110 | |
111 | 111 | CRUD::set($updatedCountKey, CRUD::get($updatedCountKey) ?? 0); |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | if (app('crud')->entry) { |
121 | 121 | app('crud')->entry = $uploader->retrieveUploadedFiles(app('crud')->entry); |
122 | 122 | } else { |
123 | - $model::retrieved(function ($entry) use ($uploader) { |
|
123 | + $model::retrieved(function($entry) use ($uploader) { |
|
124 | 124 | $entry = $uploader->retrieveUploadedFiles($entry); |
125 | 125 | }); |
126 | 126 | } |
127 | 127 | |
128 | - $model::deleting(function ($entry) use ($uploader) { |
|
128 | + $model::deleting(function($entry) use ($uploader) { |
|
129 | 129 | $uploader->deleteUploadedFiles($entry); |
130 | 130 | }); |
131 | 131 | |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | $customUploader = isset($uploaderConfiguration['uploader']) && class_exists($uploaderConfiguration['uploader']); |
148 | 148 | |
149 | 149 | if ($customUploader) { |
150 | - return $uploaderConfiguration['uploader']::for($crudObject, $uploaderConfiguration); |
|
150 | + return $uploaderConfiguration['uploader']::for ($crudObject, $uploaderConfiguration); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $uploader = app('UploadersRepository')->hasUploadFor($crudObject['type'], $this->macro); |
154 | 154 | |
155 | 155 | if ($uploader) { |
156 | - return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for($crudObject, $uploaderConfiguration); |
|
156 | + return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for ($crudObject, $uploaderConfiguration); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | throw new Exception('Undefined upload type for '.$this->crudObjectType.' type: '.$crudObject['type']); |
@@ -14,7 +14,7 @@ |
||
14 | 14 | $value = $value ?? CRUD::getRequest()->get($this->getName()); |
15 | 15 | $previousImage = $this->getPreviousFiles($entry); |
16 | 16 | |
17 | - if (! $value && $previousImage) { |
|
17 | + if (!$value && $previousImage) { |
|
18 | 18 | Storage::disk($this->getDisk())->delete($previousImage); |
19 | 19 | |
20 | 20 | return null; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | class MultipleFiles extends Uploader |
12 | 12 | { |
13 | - public static function for(array $field, $configuration): UploaderInterface |
|
13 | + public static function for (array $field, $configuration): UploaderInterface |
|
14 | 14 | { |
15 | 15 | return (new self($field, $configuration))->multiple(); |
16 | 16 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $value = $value ?? CRUD::getRequest()->file($this->getName()); |
22 | 22 | $previousFiles = $this->getPreviousFiles($entry) ?? []; |
23 | 23 | |
24 | - if (! is_array($previousFiles) && is_string($previousFiles)) { |
|
24 | + if (!is_array($previousFiles) && is_string($previousFiles)) { |
|
25 | 25 | $previousFiles = json_decode($previousFiles, true); |
26 | 26 | } |
27 | 27 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | if (in_array($previousFile, $filesToDelete)) { |
31 | 31 | Storage::disk($this->getDisk())->delete($previousFile); |
32 | 32 | |
33 | - $previousFiles = Arr::where($previousFiles, function ($value, $key) use ($previousFile) { |
|
33 | + $previousFiles = Arr::where($previousFiles, function($value, $key) use ($previousFile) { |
|
34 | 34 | return $value != $previousFile; |
35 | 35 | }); |
36 | 36 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public bool $implicit = true; |
27 | 27 | |
28 | - public static function field(string|array|ValidationRule|Rule $rules = []): self |
|
28 | + public static function field(string | array | ValidationRule | Rule $rules = []): self |
|
29 | 29 | { |
30 | 30 | $instance = new static(); |
31 | 31 | $instance->fieldRules = self::getRulesAsArray($rules); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | public function getFieldRules(): array |
76 | 76 | { |
77 | - return tap($this->fieldRules, function ($rule) { |
|
77 | + return tap($this->fieldRules, function($rule) { |
|
78 | 78 | if (is_a($rule, BackpackCustomRule::class, true)) { |
79 | 79 | $rule = $rule->getFieldRules(); |
80 | 80 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $rules = explode('|', $rules); |
90 | 90 | } |
91 | 91 | |
92 | - if (! is_array($rules)) { |
|
92 | + if (!is_array($rules)) { |
|
93 | 93 | $rules = [$rules]; |
94 | 94 | } |
95 | 95 |
@@ -9,7 +9,7 @@ |
||
9 | 9 | { |
10 | 10 | public array $fileRules; |
11 | 11 | |
12 | - public function file(string|array|ValidationRule|Rule $rules): self |
|
12 | + public function file(string | array | ValidationRule | Rule $rules): self |
|
13 | 13 | { |
14 | 14 | $this->fileRules = self::getRulesAsArray($rules); |
15 | 15 |