@@ -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 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | { |
10 | 10 | public function canPreviewAssistant(string $action, $model = null): bool |
11 | 11 | { |
12 | - if($action !== 'preview' || !$model) return false; |
|
12 | + if ($action !== 'preview' || !$model) return false; |
|
13 | 13 | |
14 | 14 | return $model instanceof ProvidesUrl; |
15 | 15 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function routePreviewAssistant(string $action, $model = null, ...$parameters): ?string |
29 | 29 | { |
30 | - if(!$this->canPreviewAssistant($action, $model)) return null; |
|
30 | + if (!$this->canPreviewAssistant($action, $model)) return null; |
|
31 | 31 | |
32 | 32 | return $model->url(); |
33 | 33 | } |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | { |
10 | 10 | public function canPreviewAssistant(string $action, $model = null): bool |
11 | 11 | { |
12 | - if($action !== 'preview' || !$model) return false; |
|
12 | + if($action !== 'preview' || !$model) { |
|
13 | + return false; |
|
14 | + } |
|
13 | 15 | |
14 | 16 | return $model instanceof ProvidesUrl; |
15 | 17 | } |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | */ |
28 | 30 | public function routePreviewAssistant(string $action, $model = null, ...$parameters): ?string |
29 | 31 | { |
30 | - if(!$this->canPreviewAssistant($action, $model)) return null; |
|
32 | + if(!$this->canPreviewAssistant($action, $model)) { |
|
33 | + return null; |
|
34 | + } |
|
31 | 35 | |
32 | 36 | return $model->url(); |
33 | 37 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | public function fragmentsIndex(string $ownerClass, $ownerId) |
56 | 56 | { |
57 | 57 | // trap($ownerClass, $ownerId); |
58 | - $models = static::managedModelClass()::whereIn('id',[2,3])->get(); |
|
58 | + $models = static::managedModelClass()::whereIn('id', [2, 3])->get(); |
|
59 | 59 | |
60 | 60 | return view('chief::back.catalogpages._fragments', [ |
61 | 61 | 'models' => $models, |
@@ -153,7 +153,7 @@ |
||
153 | 153 | 'fields' => $model->fields()->map(function (Field $field) use ($model) { |
154 | 154 | // TODO refactor so render method of field takes model and managerViewModel as arguments. |
155 | 155 | return $field->model($model) |
156 | - ->viewData(['managerViewModel' => new managerViewModel($this)]); |
|
156 | + ->viewData(['managerViewModel' => new managerViewModel($this)]); |
|
157 | 157 | }), |
158 | 158 | ]); |
159 | 159 | } |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | // Default sorted by publish date |
96 | 96 | $modelClass = static::managedModelClass(); |
97 | 97 | if (Schema::hasColumn((new $modelClass)->getTable(), 'published_at')) { |
98 | - $filters = $filters->add(HiddenFilter::make('publish', function($query){ |
|
99 | - return $query->orderBy('published_at','DESC'); |
|
98 | + $filters = $filters->add(HiddenFilter::make('publish', function($query) { |
|
99 | + return $query->orderBy('published_at', 'DESC'); |
|
100 | 100 | })); |
101 | 101 | } |
102 | 102 | |
103 | 103 | // if model has no timestamps, updated_at doesn't exist |
104 | 104 | if ((new $modelClass)->timestamps) { |
105 | - $filters = $filters->add(HiddenFilter::make('updated', function($query){ |
|
106 | - return $query->orderBy('updated_at','DESC'); |
|
105 | + $filters = $filters->add(HiddenFilter::make('updated', function($query) { |
|
106 | + return $query->orderBy('updated_at', 'DESC'); |
|
107 | 107 | })); |
108 | 108 | } |
109 | 109 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $model->saveFields($model->fields()->tagged('create'), $request->all(), $request->allFiles()); |
135 | 135 | |
136 | 136 | return redirect()->to($this->route('edit', $model)) |
137 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is toegevoegd'); |
|
137 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is toegevoegd'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | public function edit($id) |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | return view('chief::back.managers.edit', [ |
150 | 150 | 'manager' => $this, |
151 | 151 | 'model' => $model, |
152 | - 'fields' => $model->fields()->map(function (Field $field) use ($model) { |
|
152 | + 'fields' => $model->fields()->map(function(Field $field) use ($model) { |
|
153 | 153 | // TODO refactor so render method of field takes model and managerViewModel as arguments. |
154 | 154 | return $field->model($model) |
155 | 155 | ->viewData(['managerViewModel' => new managerViewModel($this)]); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $model->saveFields($model->fields(), $request->all(), $request->allFiles()); |
170 | 170 | |
171 | 171 | return redirect()->to($this->route('index')) |
172 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> <a href="'. $this->route('edit',$model) .'">' . $model->adminLabel('title') . '</a> is aangepast'); |
|
172 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> <a href="'.$this->route('edit', $model).'">'.$model->adminLabel('title').'</a> is aangepast'); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | public function delete($id, Request $request) |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | $model = static::managedModelClass()::findOrFail($id); |
180 | 180 | |
181 | 181 | if ($request->get('deleteconfirmation') !== 'DELETE') { |
182 | - return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.'); |
|
182 | + return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.'); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | app(DeleteManagedModel::class)->handle($model); |
186 | 186 | |
187 | 187 | return redirect()->to($this->route('index')) |
188 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is verwijderd.'); |
|
188 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is verwijderd.'); |
|
189 | 189 | } |
190 | 190 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | public function tagged($tags): self |
16 | 16 | { |
17 | - $tags = (array) $tags; |
|
17 | + $tags = (array)$tags; |
|
18 | 18 | |
19 | 19 | return $this->filter(function($value, $key) use($tags){ |
20 | 20 | return count(array_intersect($value, $tags)) > 0; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public function notTagged($tags): self |
25 | 25 | { |
26 | - $tags = (array) $tags; |
|
26 | + $tags = (array)$tags; |
|
27 | 27 | |
28 | 28 | return $this->filter(function($value, $key) use($tags){ |
29 | 29 | return count(array_intersect($value, $tags)) === 0; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public function untagged($tags): self |
34 | 34 | { |
35 | - $tags = (array) $tags; |
|
35 | + $tags = (array)$tags; |
|
36 | 36 | |
37 | 37 | return $this->filter(function($value, $key) use($tags){ |
38 | 38 | return empty($value); |
@@ -29,6 +29,6 @@ |
||
29 | 29 | ); |
30 | 30 | |
31 | 31 | $this->container->make(ModelToManagerMap::class)->map($class::managedModelClass(), $class); |
32 | - $this->container->make(RegisteredManagers::class)->tag($class, (array) $tags); |
|
32 | + $this->container->make(RegisteredManagers::class)->tag($class, (array)$tags); |
|
33 | 33 | } |
34 | 34 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | |
35 | 35 | public function push($managedRoutes): self |
36 | 36 | { |
37 | - return new static($this->managerClass, $this->name, array_merge($this->routes, (array) $managedRoutes)); |
|
37 | + return new static($this->managerClass, $this->name, array_merge($this->routes, (array)$managedRoutes)); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function getManagerClass(): string |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | protected function viewData(): array |
30 | 30 | { |
31 | - return array_merge( parent::viewData(),[ |
|
31 | + return array_merge(parent::viewData(), [ |
|
32 | 32 | 'options' => $this->options, |
33 | 33 | ]); |
34 | 34 | } |