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 | $uploadDefinition['uploadersGroup'] = 'withUploads'; |
41 | 41 | RegisterUploadEvents::handle($this, $uploadDefinition); |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | }); |
45 | 45 | } |
46 | 46 | |
47 | -if (! CrudField::hasMacro('withUploads')) { |
|
48 | - CrudField::macro('withUploads', function ($uploadDefinition = []) { |
|
47 | +if (!CrudField::hasMacro('withUploads')) { |
|
48 | + CrudField::macro('withUploads', function($uploadDefinition = []) { |
|
49 | 49 | /** @var CrudField|CrudColumn $this */ |
50 | 50 | $uploadDefinition['uploadersGroup'] = 'withUploads'; |
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('UploadStore')->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('UploadStore')->getUploadFor('repeatable', $uploadDefinition['uploadersGroup'] ?? null)::for($crudObject)->uploads(...$uploaderTypes); |
|
137 | + $repeatableDefinition = app('UploadStore')->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('UploadStore')->getUploadFor('repeatable', $uploadDefinition['uploadersGroup'] ?? null)::for($crudObject)->uploads(...$uploaderTypes); |
|
138 | + $repeatableDefinition = app('UploadStore')->getUploadFor('repeatable', $uploadDefinition['uploadersGroup'] ?? null)::for($crudObject) { |
|
139 | + ->uploads(...$uploaderTypes); |
|
140 | + } |
|
139 | 141 | $this->setupModelEvents($model, $repeatableDefinition); |
140 | 142 | } |
141 | 143 | } |