@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | private function saveRecord(ProvidesUrl $model, string $locale, ?string $slug, Collection $existingRecords, bool $strict = true) |
44 | 44 | { |
45 | 45 | // Existing ones for this locale? |
46 | - $nonRedirectsWithSameLocale = $existingRecords->filter(function ($record) use ($locale) { |
|
46 | + $nonRedirectsWithSameLocale = $existingRecords->filter(function($record) use ($locale) { |
|
47 | 47 | return ( |
48 | 48 | $record->locale == $locale && |
49 | 49 | !$record->isRedirect() |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | // If slug entry is left empty, all existing records will be deleted |
54 | 54 | if (!$slug) { |
55 | - $nonRedirectsWithSameLocale->each(function ($existingRecord) { |
|
55 | + $nonRedirectsWithSameLocale->each(function($existingRecord) { |
|
56 | 56 | $existingRecord->delete(); |
57 | 57 | }); |
58 | 58 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | // Only replace the existing records that differ from the current passed slugs |
72 | - $nonRedirectsWithSameLocale->each(function ($existingRecord) use ($slug) { |
|
72 | + $nonRedirectsWithSameLocale->each(function($existingRecord) use ($slug) { |
|
73 | 73 | if ($existingRecord->slug != $slug) { |
74 | 74 | $existingRecord->replaceAndRedirect(['slug' => $slug]); |
75 | 75 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $this->deleteIdenticalRedirects($sameExistingRecords, $locale, $slug); |
99 | 99 | |
100 | 100 | // Also delete any urls that match this locale and slug but are related to another model |
101 | - if(!$this->strict) { |
|
101 | + if (!$this->strict) { |
|
102 | 102 | $this->deleteIdenticalRecords($model, $sameExistingRecords); |
103 | 103 | } |
104 | 104 | } |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | */ |
113 | 113 | private function deleteIdenticalRedirects($existingRecords, $locale, $slug): void |
114 | 114 | { |
115 | - $existingRecords->filter(function ($record) use ($locale) { |
|
115 | + $existingRecords->filter(function($record) use ($locale) { |
|
116 | 116 | return ( |
117 | 117 | $record->locale == $locale && |
118 | 118 | $record->isRedirect() |
119 | 119 | ); |
120 | - })->each(function ($existingRecord) use ($slug) { |
|
120 | + })->each(function($existingRecord) use ($slug) { |
|
121 | 121 | if ($existingRecord->slug == $slug) { |
122 | 122 | $existingRecord->delete(); |
123 | 123 | } |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | { |
129 | 129 | // The old homepage url should be removed since this is no longer in effect. |
130 | 130 | // In case of any redirect to this old homepage, the last used redirect is now back in effect. |
131 | - $existingRecords->reject(function ($existingRecord) use($model) { |
|
131 | + $existingRecords->reject(function($existingRecord) use($model) { |
|
132 | 132 | return ( |
133 | 133 | $existingRecord->model_type == $model->getMorphClass() && |
134 | 134 | $existingRecord->model_id == $model->id); |
135 | - })->each(function ($existingRecord) { |
|
135 | + })->each(function($existingRecord) { |
|
136 | 136 | |
137 | 137 | // TODO: if there is a redirect to this page, we'll take this one as the new url |
138 | 138 | $existingRecord->delete(); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | public function adminLabel(string $key, $default = null, array $replace = []) |
23 | 23 | { |
24 | - if (! ($value = data_get($this->adminLabels(), $key)) ) { |
|
24 | + if (!($value = data_get($this->adminLabels(), $key))) { |
|
25 | 25 | return $default; |
26 | 26 | } |
27 | 27 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | private function adminLabels(): array |
38 | 38 | { |
39 | - $singular = Str::of(static::managedModelKey())->singular()->replace('_',' ')->__toString(); |
|
39 | + $singular = Str::of(static::managedModelKey())->singular()->replace('_', ' ')->__toString(); |
|
40 | 40 | |
41 | 41 | return [ |
42 | 42 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | 'label' => $singular, // Label used to refer to the generic model |
48 | 48 | 'nav_label' => $singular, // label used in the chief navigation |
49 | - 'page_title' => Str::of(static::managedModelKey())->plural()->replace('_',' ')->__toString(), // Generic collection title, for example used on index |
|
49 | + 'page_title' => Str::of(static::managedModelKey())->plural()->replace('_', ' ')->__toString(), // Generic collection title, for example used on index |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Instance labels |
@@ -63,17 +63,17 @@ discard block |
||
63 | 63 | |
64 | 64 | private function onlineStatusAsLabel(): string |
65 | 65 | { |
66 | - if(!$this instanceof StatefulContract) return ''; |
|
66 | + if (!$this instanceof StatefulContract) return ''; |
|
67 | 67 | |
68 | 68 | if ($this->stateOf(PageState::KEY) === PageState::PUBLISHED) { |
69 | 69 | return $this instanceof ProvidesUrl |
70 | - ? '<a href="' . $this->url() . '" target="_blank"><em>online</em></a>' |
|
70 | + ? '<a href="'.$this->url().'" target="_blank"><em>online</em></a>' |
|
71 | 71 | : '<span><em>online</em></span>'; |
72 | 72 | } |
73 | 73 | |
74 | 74 | if ($this->stateOf(PageState::KEY) === PageState::DRAFT) { |
75 | 75 | return $this instanceof ProvidesUrl |
76 | - ? '<a href="' . $this->url() . '" target="_blank" class="text-error"><em>offline</em></a>' |
|
76 | + ? '<a href="'.$this->url().'" target="_blank" class="text-error"><em>offline</em></a>' |
|
77 | 77 | : '<span class="text-error"><em>offline</em></span>'; |
78 | 78 | } |
79 | 79 |
@@ -63,7 +63,9 @@ |
||
63 | 63 | |
64 | 64 | private function onlineStatusAsLabel(): string |
65 | 65 | { |
66 | - if(!$this instanceof StatefulContract) return ''; |
|
66 | + if(!$this instanceof StatefulContract) { |
|
67 | + return ''; |
|
68 | + } |
|
67 | 69 | |
68 | 70 | if ($this->stateOf(PageState::KEY) === PageState::PUBLISHED) { |
69 | 71 | return $this instanceof ProvidesUrl |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | public function routesArchiveAssistant(): array |
21 | 21 | { |
22 | 22 | return [ |
23 | - ManagedRoute::post('archive','archive/{id}'), |
|
24 | - ManagedRoute::post('unarchive','unarchive/{id}'), |
|
23 | + ManagedRoute::post('archive', 'archive/{id}'), |
|
24 | + ManagedRoute::post('unarchive', 'unarchive/{id}'), |
|
25 | 25 | ManagedRoute::get('archive_index'), |
26 | 26 | ]; |
27 | 27 | } |
28 | 28 | |
29 | 29 | public function canArchiveAssistant(string $action, $model = null): bool |
30 | 30 | { |
31 | - if(!in_array($action, ['archive', 'unarchive', 'archive_index'])) return false; |
|
31 | + if (!in_array($action, ['archive', 'unarchive', 'archive_index'])) return false; |
|
32 | 32 | |
33 | 33 | try { |
34 | 34 | $this->authorize('update-page'); |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | |
39 | - if($action === 'archive_index') { |
|
39 | + if ($action === 'archive_index') { |
|
40 | 40 | // Archive index is only visitable when there is at least one model archived. |
41 | - if(public_method_exists($this->managedModelClass(), 'scopeArchived')) { |
|
41 | + if (public_method_exists($this->managedModelClass(), 'scopeArchived')) { |
|
42 | 42 | return $this->managedModelClass()::archived()->count() > 0; |
43 | 43 | } |
44 | 44 | return false; |
45 | 45 | } |
46 | 46 | |
47 | - if(!$model || !$model instanceof StatefulContract) return false; |
|
47 | + if (!$model || !$model instanceof StatefulContract) return false; |
|
48 | 48 | |
49 | 49 | return PageState::make($model)->can($action); |
50 | 50 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | // Ok now get all urls from this model and point them to the new records |
66 | 66 | foreach ($archivedUrlRecords as $urlRecord) { |
67 | - if ($targetRecord = $targetRecords->first(function ($record) use ($urlRecord) { |
|
67 | + if ($targetRecord = $targetRecords->first(function($record) use ($urlRecord) { |
|
68 | 68 | return ($record->locale == $urlRecord->locale && !$record->isRedirect()); |
69 | 69 | })) { |
70 | 70 | $urlRecord->redirectTo($targetRecord); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | Audit::activity()->performedOn($model)->log('archived'); |
86 | 86 | |
87 | - return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is gearchiveerd.'); |
|
87 | + return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is gearchiveerd.'); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | public function unarchive(Request $request, $id) |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | Audit::activity()->performedOn($model)->log('unarchived'); |
99 | 99 | |
100 | - return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is uit het archief gehaald.'); |
|
100 | + return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is uit het archief gehaald.'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | public function archiveIndex(Request $request) |
@@ -28,7 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | public function canArchiveAssistant(string $action, $model = null): bool |
30 | 30 | { |
31 | - if(!in_array($action, ['archive', 'unarchive', 'archive_index'])) return false; |
|
31 | + if(!in_array($action, ['archive', 'unarchive', 'archive_index'])) { |
|
32 | + return false; |
|
33 | + } |
|
32 | 34 | |
33 | 35 | try { |
34 | 36 | $this->authorize('update-page'); |
@@ -44,7 +46,9 @@ discard block |
||
44 | 46 | return false; |
45 | 47 | } |
46 | 48 | |
47 | - if(!$model || !$model instanceof StatefulContract) return false; |
|
49 | + if(!$model || !$model instanceof StatefulContract) { |
|
50 | + return false; |
|
51 | + } |
|
48 | 52 | |
49 | 53 | return PageState::make($model)->can($action); |
50 | 54 | } |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | |
29 | 29 | public function route(string $action, $model = null, ...$parameters): string |
30 | 30 | { |
31 | - foreach(DiscoverTraitMethods::belongingTo(static::class, 'route') as $method) { |
|
32 | - if(null !== ($route = $this->$method($action, $model, ...$parameters))){ |
|
31 | + foreach (DiscoverTraitMethods::belongingTo(static::class, 'route') as $method) { |
|
32 | + if (null !== ($route = $this->$method($action, $model, ...$parameters))) { |
|
33 | 33 | return $route; |
34 | 34 | } |
35 | 35 | } |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | public function can(string $action, $model = null): bool |
41 | 41 | { |
42 | - foreach(DiscoverTraitMethods::belongingTo(static::class, 'can') as $method) { |
|
43 | - if(true === $this->$method($action, $model)){ |
|
42 | + foreach (DiscoverTraitMethods::belongingTo(static::class, 'can') as $method) { |
|
43 | + if (true === $this->$method($action, $model)) { |
|
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $parameters = array_merge((array)$modelId, $parameters); |
57 | 57 | } |
58 | 58 | |
59 | - return route('chief.' . $this->managedModelClass()::managedModelKey() . '.' . $action, $parameters); |
|
59 | + return route('chief.'.$this->managedModelClass()::managedModelKey().'.'.$action, $parameters); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | private function guard(string $action, $model = null) |
@@ -18,21 +18,21 @@ discard block |
||
18 | 18 | public function routesPublishAssistant(): array |
19 | 19 | { |
20 | 20 | return [ |
21 | - ManagedRoute::post('publish','publish/{id}'), |
|
22 | - ManagedRoute::post('unpublish','unpublish/{id}'), |
|
21 | + ManagedRoute::post('publish', 'publish/{id}'), |
|
22 | + ManagedRoute::post('unpublish', 'unpublish/{id}'), |
|
23 | 23 | ]; |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function routePublishAssistant(string $action, $model = null, ...$parameters): ?string |
27 | 27 | { |
28 | - if(!$this->canPublishAssistant($action, $model)) return null; |
|
28 | + if (!$this->canPublishAssistant($action, $model)) return null; |
|
29 | 29 | |
30 | 30 | return $this->generateRoute($action, $model, ...$parameters); |
31 | 31 | } |
32 | 32 | |
33 | 33 | public function canPublishAssistant(string $action, $model = null): bool |
34 | 34 | { |
35 | - if(!in_array($action, ['publish', 'unpublish'])) return false; |
|
35 | + if (!in_array($action, ['publish', 'unpublish'])) return false; |
|
36 | 36 | |
37 | 37 | try { |
38 | 38 | $this->authorize('update-page'); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | - if(!$model || !$model instanceof StatefulContract) return false; |
|
43 | + if (!$model || !$model instanceof StatefulContract) return false; |
|
44 | 44 | |
45 | 45 | return PageState::make($model)->can($action); |
46 | 46 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | Audit::activity()->performedOn($model)->log('published'); |
57 | 57 | |
58 | - return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is online geplaatst.'); |
|
58 | + return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is online geplaatst.'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function unpublish(Request $request, $id) |
@@ -68,6 +68,6 @@ discard block |
||
68 | 68 | |
69 | 69 | Audit::activity()->performedOn($model)->log('unpublished'); |
70 | 70 | |
71 | - return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title') . ' is offline gehaald.'); |
|
71 | + return redirect()->to($this->route('index'))->with('messages.success', $model->adminLabel('title').' is offline gehaald.'); |
|
72 | 72 | } |
73 | 73 | } |
@@ -25,14 +25,18 @@ discard block |
||
25 | 25 | |
26 | 26 | public function routePublishAssistant(string $action, $model = null, ...$parameters): ?string |
27 | 27 | { |
28 | - if(!$this->canPublishAssistant($action, $model)) return null; |
|
28 | + if(!$this->canPublishAssistant($action, $model)) { |
|
29 | + return null; |
|
30 | + } |
|
29 | 31 | |
30 | 32 | return $this->generateRoute($action, $model, ...$parameters); |
31 | 33 | } |
32 | 34 | |
33 | 35 | public function canPublishAssistant(string $action, $model = null): bool |
34 | 36 | { |
35 | - if(!in_array($action, ['publish', 'unpublish'])) return false; |
|
37 | + if(!in_array($action, ['publish', 'unpublish'])) { |
|
38 | + return false; |
|
39 | + } |
|
36 | 40 | |
37 | 41 | try { |
38 | 42 | $this->authorize('update-page'); |
@@ -40,7 +44,9 @@ discard block |
||
40 | 44 | return false; |
41 | 45 | } |
42 | 46 | |
43 | - if(!$model || !$model instanceof StatefulContract) return false; |
|
47 | + if(!$model || !$model instanceof StatefulContract) { |
|
48 | + return false; |
|
49 | + } |
|
44 | 50 | |
45 | 51 | return PageState::make($model)->can($action); |
46 | 52 | } |
@@ -39,7 +39,9 @@ discard block |
||
39 | 39 | |
40 | 40 | public function canCrudAssistant(string $action, $model = null): bool |
41 | 41 | { |
42 | - if(!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) return false; |
|
42 | + if(!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) { |
|
43 | + return false; |
|
44 | + } |
|
43 | 45 | |
44 | 46 | try { |
45 | 47 | |
@@ -58,9 +60,13 @@ discard block |
||
58 | 60 | return false; |
59 | 61 | } |
60 | 62 | |
61 | - if(in_array($action, ['index', 'create', 'store'])) return true; |
|
63 | + if(in_array($action, ['index', 'create', 'store'])) { |
|
64 | + return true; |
|
65 | + } |
|
62 | 66 | |
63 | - if(!$model || !$model instanceof StatefulContract) return true; |
|
67 | + if(!$model || !$model instanceof StatefulContract) { |
|
68 | + return true; |
|
69 | + } |
|
64 | 70 | |
65 | 71 | // Model cannot be in deleted state for editing purposes. |
66 | 72 | if(in_array($action, ['edit', 'update'])) { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function canCrudAssistant(string $action, $model = null): bool |
39 | 39 | { |
40 | - if(!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) return false; |
|
40 | + if (!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) return false; |
|
41 | 41 | |
42 | 42 | try { |
43 | 43 | |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | return false; |
57 | 57 | } |
58 | 58 | |
59 | - if(in_array($action, ['index', 'create', 'store'])) return true; |
|
59 | + if (in_array($action, ['index', 'create', 'store'])) return true; |
|
60 | 60 | |
61 | - if(!$model || !$model instanceof StatefulContract) return true; |
|
61 | + if (!$model || !$model instanceof StatefulContract) return true; |
|
62 | 62 | |
63 | 63 | // Model cannot be in deleted state for editing purposes. |
64 | - if(in_array($action, ['edit', 'update'])) { |
|
64 | + if (in_array($action, ['edit', 'update'])) { |
|
65 | 65 | return !($model->stateOf(PageState::KEY) == PageState::DELETED); |
66 | 66 | } |
67 | 67 | |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | // Default sorted by publish date |
100 | 100 | $modelClass = $this->managedModelClass(); |
101 | 101 | if (Schema::hasColumn((new $modelClass)->getTable(), 'published_at')) { |
102 | - $filters = $filters->add(HiddenFilter::make('publish', function ($query) { |
|
102 | + $filters = $filters->add(HiddenFilter::make('publish', function($query) { |
|
103 | 103 | return $query->orderBy('published_at', 'DESC'); |
104 | 104 | })); |
105 | 105 | } |
106 | 106 | |
107 | 107 | // if model has no timestamps, updated_at doesn't exist |
108 | 108 | if ((new $modelClass)->timestamps) { |
109 | - $filters = $filters->add(HiddenFilter::make('updated', function ($query) { |
|
109 | + $filters = $filters->add(HiddenFilter::make('updated', function($query) { |
|
110 | 110 | return $query->orderBy('updated_at', 'DESC'); |
111 | 111 | })); |
112 | 112 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $model->saveFields($model->fields()->notTagged('edit'), $request->all(), $request->allFiles()); |
141 | 141 | |
142 | 142 | return redirect()->to($this->route('edit', $model)) |
143 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is toegevoegd'); |
|
143 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is toegevoegd'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | public function edit(Request $request, $id) |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $model->saveFields($model->fields()->notTagged('create'), $request->all(), $request->allFiles()); |
168 | 168 | |
169 | 169 | return redirect()->to($this->route('index')) |
170 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> <a href="' . $this->route('edit', $model) . '">' . $model->adminLabel('title') . '</a> is aangepast'); |
|
170 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> <a href="'.$this->route('edit', $model).'">'.$model->adminLabel('title').'</a> is aangepast'); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | public function delete(Request $request, $id) |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | $this->guard('delete', $model); |
178 | 178 | |
179 | 179 | if ($request->get('deleteconfirmation') !== 'DELETE') { |
180 | - return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.'); |
|
180 | + return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | app(DeleteModel::class)->handle($model); |
184 | 184 | |
185 | 185 | return redirect()->to($this->route('index')) |
186 | - ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "' . $model->adminLabel('title') . '" is verwijderd.'); |
|
186 | + ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i> "'.$model->adminLabel('title').'" is verwijderd.'); |
|
187 | 187 | } |
188 | 188 | } |
@@ -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]; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | - $method = 'get' . ucfirst($key); |
|
111 | + $method = 'get'.ucfirst($key); |
|
112 | 112 | |
113 | 113 | // Reject from list if value does not match expected one |
114 | 114 | if ($value && $value == $field->$method()) { |
@@ -124,23 +124,23 @@ discard block |
||
124 | 124 | |
125 | 125 | public function render(): string |
126 | 126 | { |
127 | - return array_reduce($this->fields, function (string $carry, Field $field) { |
|
128 | - return $carry . $field->render(); |
|
127 | + return array_reduce($this->fields, function(string $carry, Field $field) { |
|
128 | + return $carry.$field->render(); |
|
129 | 129 | }, ''); |
130 | 130 | } |
131 | 131 | |
132 | 132 | public function keyed($key): Fields |
133 | 133 | { |
134 | - $keys = (array) $key; |
|
134 | + $keys = (array)$key; |
|
135 | 135 | |
136 | - return new static(array_filter($this->fields, function (Field $field) use ($keys) { |
|
136 | + return new static(array_filter($this->fields, function(Field $field) use ($keys) { |
|
137 | 137 | return in_array($field->getKey(), $keys); |
138 | 138 | })); |
139 | 139 | } |
140 | 140 | |
141 | 141 | public function tagged($tag): Fields |
142 | 142 | { |
143 | - return new static(array_filter($this->fields, function (Field $field) use ($tag) { |
|
143 | + return new static(array_filter($this->fields, function(Field $field) use ($tag) { |
|
144 | 144 | return $field->tagged($tag); |
145 | 145 | })); |
146 | 146 | } |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | public function notTagged($tag): Fields |
149 | 149 | { |
150 | 150 | // TODO: to test this... |
151 | - return new static(array_filter($this->fields, function (Field $field) use ($tag) { |
|
151 | + return new static(array_filter($this->fields, function(Field $field) use ($tag) { |
|
152 | 152 | return !$field->tagged($tag); |
153 | 153 | })); |
154 | 154 | } |
155 | 155 | |
156 | 156 | public function untagged(): Fields |
157 | 157 | { |
158 | - return new static(array_filter($this->fields, function (Field $field) { |
|
158 | + return new static(array_filter($this->fields, function(Field $field) { |
|
159 | 159 | return $field->untagged(); |
160 | 160 | })); |
161 | 161 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | public function offsetGet($offset) |
198 | 198 | { |
199 | 199 | if (!isset($this->fields[$offset])) { |
200 | - throw new \RuntimeException('No field found by key [' . $offset . ']'); |
|
200 | + throw new \RuntimeException('No field found by key ['.$offset.']'); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | return $this->fields[$offset]; |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | public function offsetSet($offset, $value) |
207 | 207 | { |
208 | 208 | if (!$value instanceof Field) { |
209 | - throw new \InvalidArgumentException('Passed value must be of type ' . Field::class); |
|
209 | + throw new \InvalidArgumentException('Passed value must be of type '.Field::class); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | $this->fields[$offset] = $value; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | private function validateFields(array $fields) |
238 | 238 | { |
239 | - array_map(function (Field $field) { |
|
239 | + array_map(function(Field $field) { |
|
240 | 240 | }, $fields); |
241 | 241 | } |
242 | 242 |
@@ -53,13 +53,13 @@ |
||
53 | 53 | |
54 | 54 | if ($child instanceof Module && $child->isPageSpecific()) { |
55 | 55 | $duplicatedChild = $child::create([ |
56 | - 'slug' => $targetModel->title ? $targetModel->title . '-' . $child->slug : $child->slug . '-copy', |
|
56 | + 'slug' => $targetModel->title ? $targetModel->title.'-'.$child->slug : $child->slug.'-copy', |
|
57 | 57 | 'owner_id' => $targetModel->id, |
58 | 58 | 'owner_type' => $targetModel->getMorphClass() |
59 | 59 | ]); |
60 | 60 | |
61 | 61 | $this->moduleTemplateApplicator->handle($child, $duplicatedChild); |
62 | - } else { |
|
62 | + }else { |
|
63 | 63 | $duplicatedChild = $child; |
64 | 64 | } |
65 | 65 |
@@ -22,12 +22,12 @@ |
||
22 | 22 | |
23 | 23 | public function handle($sourceModel, $targetModel): void |
24 | 24 | { |
25 | - if(!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) return; |
|
25 | + if (!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) return; |
|
26 | 26 | |
27 | 27 | $copiedContext = ContextModel::createForOwner($targetModel); |
28 | 28 | |
29 | 29 | /** @var FragmentModel $fragment */ |
30 | - foreach($context->fragments as $fragment) { |
|
30 | + foreach ($context->fragments as $fragment) { |
|
31 | 31 | $copiedFragment = $fragment->replicate(['context_id']); |
32 | 32 | $copiedFragment->id = $this->fragmentRepository->nextId(); |
33 | 33 | $copiedFragment->context_id = $copiedContext->id; |
@@ -22,7 +22,9 @@ |
||
22 | 22 | |
23 | 23 | public function handle($sourceModel, $targetModel): void |
24 | 24 | { |
25 | - if(!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) return; |
|
25 | + if(!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) { |
|
26 | + return; |
|
27 | + } |
|
26 | 28 | |
27 | 29 | $copiedContext = ContextModel::createForOwner($targetModel); |
28 | 30 |