@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | // Mark the slug as deleted to avoid any conflict with newly created modules with the same slug. |
23 | 23 | $module->update([ |
24 | - 'slug' => $module->slug . $this->appendDeleteMarker(), |
|
24 | + 'slug' => $module->slug.$this->appendDeleteMarker(), |
|
25 | 25 | ]); |
26 | 26 | |
27 | 27 | $module->delete(); |
@@ -35,6 +35,6 @@ discard block |
||
35 | 35 | |
36 | 36 | private function appendDeleteMarker(): string |
37 | 37 | { |
38 | - return '_DELETED_' . time(); |
|
38 | + return '_DELETED_'.time(); |
|
39 | 39 | } |
40 | 40 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if (is_string($file) && isset(json_decode($file)->output)) { |
113 | 113 | $image_name = json_decode($file)->output->name; |
114 | 114 | $asset = app(AddAsset::class)->add($model, json_decode($file)->output->image, $type, $locale, $this->sluggifyFilename($image_name)); |
115 | - } else { |
|
115 | + }else { |
|
116 | 116 | if ($file instanceof UploadedFile) { |
117 | 117 | $image_name = $file->getClientOriginalName(); |
118 | 118 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | if (false !== ($key = array_search($image_name, $files_order))) { |
124 | 124 | $files_order[$key] = (string)$asset->id; |
125 | 125 | } |
126 | - } else { |
|
126 | + }else { |
|
127 | 127 | $file = Asset::find($file); |
128 | 128 | if ($file) { |
129 | 129 | if ($model->assetRelation()->where('asset_pivots.type', $type)->where('asset_pivots.locale', $locale)->get()->contains($file)) { |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | */ |
143 | 143 | private function sluggifyFilename($filename): string |
144 | 144 | { |
145 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
145 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
146 | 146 | $filename = substr($filename, 0, strrpos($filename, '.')); |
147 | - $filename = Str::slug($filename) . '.' . $extension; |
|
147 | + $filename = Str::slug($filename).'.'.$extension; |
|
148 | 148 | |
149 | 149 | return $filename; |
150 | 150 | } |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | if ($file instanceof UploadedFile && !$file->isValid()) { |
161 | 161 | if ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
162 | 162 | throw new FileTooBigException( |
163 | - 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' . |
|
164 | - 'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' . |
|
165 | - 'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB' |
|
163 | + 'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '. |
|
164 | + 'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '. |
|
165 | + 'post_max_size: '.(int)(ini_get('post_max_size')).'MB' |
|
166 | 166 | ); |
167 | 167 | } |
168 | 168 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | foreach ($files as $locale => $_files) { |
178 | 178 | foreach ($_files as $action => $file) { |
179 | 179 | if (!in_array($action, $actions)) { |
180 | - throw new \InvalidArgumentException('A valid files entry should have a key of either [' . implode(',', $actions) . ']. Instead ' . $action . ' is given.'); |
|
180 | + throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.'); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | } |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | return $filename; |
141 | 141 | } |
142 | 142 | |
143 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
143 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
144 | 144 | $filename = substr($filename, 0, strrpos($filename, '.')); |
145 | 145 | |
146 | - return Str::slug($filename) . '.' . $extension; |
|
146 | + return Str::slug($filename).'.'.$extension; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | protected function sort(HasAsset $model, MediaField $field, array $input) |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | $values = isset($fileIdInput[$key]) |
170 | 170 | ? $fileIdInput[$key] |
171 | 171 | : ( |
172 | - isset($fileIdInput['files-' . $key]) |
|
173 | - ? $fileIdInput['files-' . $key] |
|
172 | + isset($fileIdInput['files-'.$key]) |
|
173 | + ? $fileIdInput['files-'.$key] |
|
174 | 174 | : '' |
175 | 175 | ); |
176 | 176 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | { |
15 | 15 | public function handle(HasAsset $model, MediaField $field, array $input, array $files): void |
16 | 16 | { |
17 | - foreach ([data_get($files, 'files.' . $field->getName(), []), data_get($input, 'files.' . $field->getName(), [])] as $requestPayload) { |
|
17 | + foreach ([data_get($files, 'files.'.$field->getName(), []), data_get($input, 'files.'.$field->getName(), [])] as $requestPayload) { |
|
18 | 18 | foreach ($requestPayload as $locale => $values) { |
19 | 19 | $this->handlePayload($model, $field, $locale, $values); |
20 | 20 | } |
@@ -159,7 +159,7 @@ |
||
159 | 159 | if (is_array_empty($translation)) { |
160 | 160 | |
161 | 161 | // Nullify all values |
162 | - $trans[$locale] = array_map(function ($value) { |
|
162 | + $trans[$locale] = array_map(function($value) { |
|
163 | 163 | return null; |
164 | 164 | }, $translation); |
165 | 165 | continue; |
@@ -43,16 +43,16 @@ |
||
43 | 43 | $filename = $filePayload['filename']; |
44 | 44 | |
45 | 45 | if (!$asset = AssetUploader::uploadFromBase64($base64EncodedFile, $filename)) { |
46 | - $responseContent['file-' . rand(1 - 999)] = [ |
|
46 | + $responseContent['file-'.rand(1-999)] = [ |
|
47 | 47 | 'error' => true, |
48 | - 'messages' => 'Afbeelding [' . $filename . '] kan niet worden opgeladen.', |
|
48 | + 'messages' => 'Afbeelding ['.$filename.'] kan niet worden opgeladen.', |
|
49 | 49 | ]; |
50 | 50 | continue; |
51 | 51 | } |
52 | 52 | |
53 | 53 | app(AddAsset::class)->add($model, $asset, MediaType::CONTENT, $request->input('locale', app()->getLocale())); |
54 | 54 | |
55 | - $responseContent['file-' . $asset->id] = [ |
|
55 | + $responseContent['file-'.$asset->id] = [ |
|
56 | 56 | 'url' => $asset->url(), |
57 | 57 | 'id' => $asset->id, |
58 | 58 | ]; |
@@ -41,7 +41,7 @@ |
||
41 | 41 | if ($urlRecord->isRedirect()) { |
42 | 42 | return 'Deze link bestaat reeds als redirect. Deze redirect zal bijgevolg worden verwijderd.'; |
43 | 43 | } |
44 | - return 'Deze link bestaat reeds. Kies een andere of <a target="_blank" href="' . $this->editRouteOfOtherModel($urlRecord) . '">pas de andere pagina aan</a>.'; |
|
44 | + return 'Deze link bestaat reeds. Kies een andere of <a target="_blank" href="'.$this->editRouteOfOtherModel($urlRecord).'">pas de andere pagina aan</a>.'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | private function editRouteOfOtherModel(UrlRecord $urlRecord): string |
@@ -27,7 +27,9 @@ discard block |
||
27 | 27 | |
28 | 28 | public function canArchiveAssistant(string $action, $model = null): bool |
29 | 29 | { |
30 | - if(!in_array($action, ['archive', 'unarchive', 'archive_index'])) return false; |
|
30 | + if(!in_array($action, ['archive', 'unarchive', 'archive_index'])) { |
|
31 | + return false; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | if($action === 'archive_index') { |
33 | 35 | // Archive index is only visitable when there is at least one model archived. |
@@ -37,7 +39,9 @@ discard block |
||
37 | 39 | return false; |
38 | 40 | } |
39 | 41 | |
40 | - if(!$model || !$model instanceof StatefulContract) return false; |
|
42 | + if(!$model || !$model instanceof StatefulContract) { |
|
43 | + return false; |
|
44 | + } |
|
41 | 45 | |
42 | 46 | return PageState::make($model)->can($action); |
43 | 47 | } |
@@ -19,25 +19,25 @@ discard block |
||
19 | 19 | public function routesArchiveAssistant(): array |
20 | 20 | { |
21 | 21 | return [ |
22 | - ManagedRoute::post('archive','archive/{id}'), |
|
23 | - ManagedRoute::post('unarchive','unarchive/{id}'), |
|
22 | + ManagedRoute::post('archive', 'archive/{id}'), |
|
23 | + ManagedRoute::post('unarchive', 'unarchive/{id}'), |
|
24 | 24 | ManagedRoute::get('archive_index'), |
25 | 25 | ]; |
26 | 26 | } |
27 | 27 | |
28 | 28 | public function canArchiveAssistant(string $action, $model = null): bool |
29 | 29 | { |
30 | - if(!in_array($action, ['archive', 'unarchive', 'archive_index'])) return false; |
|
30 | + if (!in_array($action, ['archive', 'unarchive', 'archive_index'])) return false; |
|
31 | 31 | |
32 | - if($action === 'archive_index') { |
|
32 | + if ($action === 'archive_index') { |
|
33 | 33 | // Archive index is only visitable when there is at least one model archived. |
34 | - if(public_method_exists($this->managedModelClass(), 'scopeArchived')) { |
|
34 | + if (public_method_exists($this->managedModelClass(), 'scopeArchived')) { |
|
35 | 35 | return $this->managedModelClass()::archived()->count() > 0; |
36 | 36 | } |
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
40 | - if(!$model || !$model instanceof StatefulContract) return false; |
|
40 | + if (!$model || !$model instanceof StatefulContract) return false; |
|
41 | 41 | |
42 | 42 | return PageState::make($model)->can($action); |
43 | 43 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | // Ok now get all urls from this model and point them to the new records |
58 | 58 | foreach (UrlRecord::getByModel($model) as $urlRecord) { |
59 | - if ($targetRecord = $targetRecords->first(function ($record) use ($urlRecord) { |
|
59 | + if ($targetRecord = $targetRecords->first(function($record) use ($urlRecord) { |
|
60 | 60 | return ($record->locale == $urlRecord->locale && !$record->isRedirect()); |
61 | 61 | })) { |
62 | 62 | $urlRecord->redirectTo($targetRecord); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | Audit::activity()->performedOn($model)->log('archived'); |
70 | 70 | |
71 | - return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is gearchiveerd.'); |
|
71 | + return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is gearchiveerd.'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function unarchive(Request $request, $id) |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | Audit::activity()->performedOn($model)->log('unarchived'); |
83 | 83 | |
84 | - return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is uit het archief gehaald.'); |
|
84 | + return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is uit het archief gehaald.'); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public function archive_index(Request $request) |
@@ -24,16 +24,22 @@ |
||
24 | 24 | |
25 | 25 | public function routePublishAssistant(string $action, $model = null, ...$parameters): ?string |
26 | 26 | { |
27 | - if(!$this->canPublishAssistant($action, $model)) return null; |
|
27 | + if(!$this->canPublishAssistant($action, $model)) { |
|
28 | + return null; |
|
29 | + } |
|
28 | 30 | |
29 | 31 | return $this->generateRoute($action, $model, ...$parameters); |
30 | 32 | } |
31 | 33 | |
32 | 34 | public function canPublishAssistant(string $action, $model = null): bool |
33 | 35 | { |
34 | - if(!in_array($action, ['publish', 'unpublish'])) return false; |
|
36 | + if(!in_array($action, ['publish', 'unpublish'])) { |
|
37 | + return false; |
|
38 | + } |
|
35 | 39 | |
36 | - if(!$model || !$model instanceof StatefulContract) return false; |
|
40 | + if(!$model || !$model instanceof StatefulContract) { |
|
41 | + return false; |
|
42 | + } |
|
37 | 43 | |
38 | 44 | return PageState::make($model)->can($action); |
39 | 45 | } |
@@ -17,23 +17,23 @@ discard block |
||
17 | 17 | public function routesPublishAssistant(): array |
18 | 18 | { |
19 | 19 | return [ |
20 | - ManagedRoute::post('publish','publish/{id}'), |
|
21 | - ManagedRoute::post('unpublish','unpublish/{id}'), |
|
20 | + ManagedRoute::post('publish', 'publish/{id}'), |
|
21 | + ManagedRoute::post('unpublish', 'unpublish/{id}'), |
|
22 | 22 | ]; |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function routePublishAssistant(string $action, $model = null, ...$parameters): ?string |
26 | 26 | { |
27 | - if(!$this->canPublishAssistant($action, $model)) return null; |
|
27 | + if (!$this->canPublishAssistant($action, $model)) return null; |
|
28 | 28 | |
29 | 29 | return $this->generateRoute($action, $model, ...$parameters); |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function canPublishAssistant(string $action, $model = null): bool |
33 | 33 | { |
34 | - if(!in_array($action, ['publish', 'unpublish'])) return false; |
|
34 | + if (!in_array($action, ['publish', 'unpublish'])) return false; |
|
35 | 35 | |
36 | - if(!$model || !$model instanceof StatefulContract) return false; |
|
36 | + if (!$model || !$model instanceof StatefulContract) return false; |
|
37 | 37 | |
38 | 38 | return PageState::make($model)->can($action); |
39 | 39 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | Audit::activity()->performedOn($model)->log('published'); |
50 | 50 | |
51 | - return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is online geplaatst.'); |
|
51 | + return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is online geplaatst.'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function unpublish(Request $request, $id) |
@@ -61,6 +61,6 @@ discard block |
||
61 | 61 | |
62 | 62 | Audit::activity()->performedOn($model)->log('unpublished'); |
63 | 63 | |
64 | - return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is offline gehaald.'); |
|
64 | + return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is offline gehaald.'); |
|
65 | 65 | } |
66 | 66 | } |