@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | // TODO: how to assign for pagebuilder?? with tag, via the chief relations config or is this default |
37 | 37 | $moduleManagerClasses = $this->registeredManagers->tagged('module')->get(); |
38 | 38 | |
39 | - $managers = collect(array_map(function($moduleManagerClass){ |
|
39 | + $managers = collect(array_map(function($moduleManagerClass) { |
|
40 | 40 | return app($moduleManagerClass); |
41 | 41 | }, $moduleManagerClasses)); |
42 | 42 | |
43 | 43 | return $managers |
44 | - ->reject(function($manager){ return !$manager->can('create'); }) |
|
44 | + ->reject(function($manager) { return !$manager->can('create'); }) |
|
45 | 45 | ->map(function($manager) use($ownerType, $ownerId){ |
46 | 46 | return [ |
47 | 47 | 'label' => $manager->adminLabel('page_title'), |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | // Get the modules that are set to be shareable. |
57 | 57 | $moduleManagerClasses = $this->shareableModules(); |
58 | 58 | |
59 | - $managers = collect(array_map(function($moduleManagerClass){ |
|
59 | + $managers = collect(array_map(function($moduleManagerClass) { |
|
60 | 60 | return app($moduleManagerClass); |
61 | 61 | }, $moduleManagerClasses)); |
62 | 62 | |
63 | 63 | return $managers |
64 | - ->reject(function($manager){ return !$manager->can('create-shared'); }) |
|
65 | - ->map(function($manager){ |
|
64 | + ->reject(function($manager) { return !$manager->can('create-shared'); }) |
|
65 | + ->map(function($manager) { |
|
66 | 66 | return [ |
67 | 67 | 'label' => $manager->adminLabel('page_title'), |
68 | 68 | 'value' => $manager->route('create-shared') |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $model->saveFields($model->fields()->tagged('create'), $request->all(), $request->allFiles()); |
92 | 92 | |
93 | 93 | return redirect()->to($this->route('edit', $model)) |
94 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is toegevoegd'); |
|
94 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is toegevoegd'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | public function edit($id) |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | return view('chief::back.managers.edit', [ |
107 | 107 | 'model' => $model, |
108 | 108 | 'managerViewModel' => $this->managerViewModel(), |
109 | - 'fields' => $model->fields()->map(function (Field $field) use ($model) { |
|
109 | + 'fields' => $model->fields()->map(function(Field $field) use ($model) { |
|
110 | 110 | // TODO refactor so render method of field takes model and managerViewModel as arguments. |
111 | 111 | return $field->model($model) |
112 | 112 | ->viewData(['managerViewModel' => $this->managerViewModel()]); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $model->saveFields($model->fields(), $request->all(), $request->allFiles()); |
127 | 127 | |
128 | 128 | return redirect()->to($this->route('edit', $model)) |
129 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is aangepast'); |
|
129 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is aangepast'); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | public function delete($id, Request $request) |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | $model = static::managedModelClass()::findOrFail($id); |
137 | 137 | |
138 | 138 | if ($request->get('deleteconfirmation') !== 'DELETE') { |
139 | - return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.'); |
|
139 | + return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | app(DeleteManagedModel::class)->handle($model); |
143 | 143 | |
144 | 144 | return redirect()->to($this->route('index')) |
145 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is verwijderd.'); |
|
145 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is verwijderd.'); |
|
146 | 146 | } |
147 | 147 | } |
@@ -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; |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | public function find(string $key): Field |
42 | 42 | { |
43 | - if(!isset($this->fields[$key])) { |
|
44 | - throw new \InvalidArgumentException('No field found by key ' . $key); |
|
43 | + if (!isset($this->fields[$key])) { |
|
44 | + throw new \InvalidArgumentException('No field found by key '.$key); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | return $this->fields[$key]; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | continue; |
102 | 102 | } |
103 | 103 | |
104 | - $method = 'get' . ucfirst($key); |
|
104 | + $method = 'get'.ucfirst($key); |
|
105 | 105 | |
106 | 106 | // Reject from list if value does not match expected one |
107 | 107 | if ($value && $value == $field->$method()) { |
@@ -117,30 +117,30 @@ discard block |
||
117 | 117 | |
118 | 118 | public function render(): string |
119 | 119 | { |
120 | - return array_reduce($this->fields, function (string $carry, Field $field) { |
|
121 | - return $carry . $field->render(); |
|
120 | + return array_reduce($this->fields, function(string $carry, Field $field) { |
|
121 | + return $carry.$field->render(); |
|
122 | 122 | }, ''); |
123 | 123 | } |
124 | 124 | |
125 | 125 | public function keyed($key): Fields |
126 | 126 | { |
127 | - $keys = (array) $key; |
|
127 | + $keys = (array)$key; |
|
128 | 128 | |
129 | - return new static(array_filter($this->fields, function (Field $field) use ($keys) { |
|
129 | + return new static(array_filter($this->fields, function(Field $field) use ($keys) { |
|
130 | 130 | return in_array($field->getKey(), $keys); |
131 | 131 | })); |
132 | 132 | } |
133 | 133 | |
134 | 134 | public function tagged($tag): Fields |
135 | 135 | { |
136 | - return new static(array_filter($this->fields, function (Field $field) use ($tag) { |
|
136 | + return new static(array_filter($this->fields, function(Field $field) use ($tag) { |
|
137 | 137 | return $field->tagged($tag); |
138 | 138 | })); |
139 | 139 | } |
140 | 140 | |
141 | 141 | public function untagged(): Fields |
142 | 142 | { |
143 | - return new static(array_filter($this->fields, function (Field $field) { |
|
143 | + return new static(array_filter($this->fields, function(Field $field) { |
|
144 | 144 | return $field->untagged(); |
145 | 145 | })); |
146 | 146 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | public function offsetGet($offset) |
183 | 183 | { |
184 | 184 | if (!isset($this->fields[$offset])) { |
185 | - throw new \RuntimeException('No field found by key [' . $offset . ']'); |
|
185 | + throw new \RuntimeException('No field found by key ['.$offset.']'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $this->fields[$offset]; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | public function offsetSet($offset, $value) |
192 | 192 | { |
193 | 193 | if (!$value instanceof Field) { |
194 | - throw new \InvalidArgumentException('Passed value must be of type ' . Field::class); |
|
194 | + throw new \InvalidArgumentException('Passed value must be of type '.Field::class); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | $this->fields[$offset] = $value; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | private function validateFields(array $fields) |
223 | 223 | { |
224 | - array_map(function (Field $field) { |
|
224 | + array_map(function(Field $field) { |
|
225 | 225 | }, $fields); |
226 | 226 | } |
227 | 227 |
@@ -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 |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | public function route(string $action, $model = null, ...$parameters): string |
28 | 28 | { |
29 | - foreach(DiscoverTraitMethods::belongingTo(static::class, 'route') as $method) { |
|
30 | - if(null !== ($route = $this->$method($action, $model, ...$parameters))){ |
|
29 | + foreach (DiscoverTraitMethods::belongingTo(static::class, 'route') as $method) { |
|
30 | + if (null !== ($route = $this->$method($action, $model, ...$parameters))) { |
|
31 | 31 | return $route; |
32 | 32 | } |
33 | 33 | } |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | public function can(string $action, $model = null): bool |
42 | 42 | { |
43 | - foreach(DiscoverTraitMethods::belongingTo(static::class, 'can') as $method) { |
|
44 | - if(true === $this->$method($action, $model)){ |
|
43 | + foreach (DiscoverTraitMethods::belongingTo(static::class, 'can') as $method) { |
|
44 | + if (true === $this->$method($action, $model)) { |
|
45 | 45 | return true; |
46 | 46 | } |
47 | 47 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $parameters = array_merge((array)$modelId, $parameters); |
84 | 84 | } |
85 | 85 | |
86 | - return route('chief.' . static::routeKey() . '.' . $action, $parameters); |
|
86 | + return route('chief.'.static::routeKey().'.'.$action, $parameters); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | private function guard(string $action) |
@@ -19,25 +19,25 @@ discard block |
||
19 | 19 | public static 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(static::managedModelClass(), 'scopeArchived')) { |
|
34 | + if (public_method_exists(static::managedModelClass(), 'scopeArchived')) { |
|
35 | 35 | return static::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($id, Request $request) |
@@ -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) |
@@ -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 | } |
@@ -17,23 +17,23 @@ discard block |
||
17 | 17 | public static 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($id, Request $request) |
@@ -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 | } |
@@ -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 | } |