@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | { |
9 | 9 | public static function toSelectValues(Collection $collection): Collection |
10 | 10 | { |
11 | - return $collection->map(function (ProvidesFlatReference $item) { |
|
11 | + return $collection->map(function(ProvidesFlatReference $item) { |
|
12 | 12 | return [ |
13 | 13 | 'id' => $item->flatReference()->get(), |
14 | 14 | 'label' => $item->flatReferenceLabel(), |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | { |
22 | 22 | $grouped = []; |
23 | 23 | |
24 | - static::toSelectValues($collection)->each(function ($item) use (&$grouped) { |
|
24 | + static::toSelectValues($collection)->each(function($item) use (&$grouped) { |
|
25 | 25 | if (isset($grouped[$item['group']])) { |
26 | 26 | $grouped[$item['group']]['values'][] = $item; |
27 | - } else { |
|
27 | + }else { |
|
28 | 28 | $grouped[$item['group']] = ['group' => $item['group'], 'values' => [$item]]; |
29 | 29 | } |
30 | 30 | }); |
@@ -21,16 +21,16 @@ |
||
21 | 21 | $referenceStrings = []; |
22 | 22 | } |
23 | 23 | |
24 | - return (new Collection($referenceStrings))->reject(function ($referenceString) { |
|
24 | + return (new Collection($referenceStrings))->reject(function($referenceString) { |
|
25 | 25 | return is_null($referenceString); |
26 | - })->map(function ($referenceString) { |
|
26 | + })->map(function($referenceString) { |
|
27 | 27 | return FlatReferenceFactory::fromString($referenceString)->instance(); |
28 | 28 | }); |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function toFlatReferences(): Collection |
32 | 32 | { |
33 | - return (new Collection($this->all()))->map(function (ProvidesFlatReference $item) { |
|
33 | + return (new Collection($this->all()))->map(function(ProvidesFlatReference $item) { |
|
34 | 34 | return $item->flatReference()->get(); |
35 | 35 | }); |
36 | 36 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | public static function fromString(string $reference): FlatReference |
8 | 8 | { |
9 | 9 | if (false == strpos($reference, '@')) { |
10 | - throw new \InvalidArgumentException('Invalid reference composition. A flat reference should honour schema <class>@<id>. [' . $reference . '] was passed instead.'); |
|
10 | + throw new \InvalidArgumentException('Invalid reference composition. A flat reference should honour schema <class>@<id>. ['.$reference.'] was passed instead.'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | list($className, $id) = explode('@', $reference); |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | $instance = app($className); |
16 | 16 | $instance->{$instance->getKeyName()} = $id; |
17 | 17 | |
18 | - if (! method_exists($instance, 'flatReference')) { |
|
19 | - throw new \InvalidArgumentException('Instance created from model reference [' . $reference . '] was expected to have a method of flatReference() but is has not.'); |
|
18 | + if (!method_exists($instance, 'flatReference')) { |
|
19 | + throw new \InvalidArgumentException('Instance created from model reference ['.$reference.'] was expected to have a method of flatReference() but is has not.'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | return $instance->flatReference(); |
@@ -90,11 +90,11 @@ |
||
90 | 90 | return new Fields([ |
91 | 91 | $this->pageBuilderField(), |
92 | 92 | InputField::make('title')->translatable($this->model->availableLocales()) |
93 | - ->validation('required-fallback-locale|max:200', [], [ |
|
94 | - 'trans.'.config('app.fallback_locale', 'nl').'.title' => 'title', |
|
95 | - ]) |
|
96 | - ->label('De titel van je '.$this->model->labelSingular ?? 'pagina') |
|
97 | - ->description('Dit is de titel die zal worden getoond in de overzichten en modules.<br> Deze zal gebruikt worden als interne titel en slug van de nieuwe pagina.'), |
|
93 | + ->validation('required-fallback-locale|max:200', [], [ |
|
94 | + 'trans.'.config('app.fallback_locale', 'nl').'.title' => 'title', |
|
95 | + ]) |
|
96 | + ->label('De titel van je '.$this->model->labelSingular ?? 'pagina') |
|
97 | + ->description('Dit is de titel die zal worden getoond in de overzichten en modules.<br> Deze zal gebruikt worden als interne titel en slug van de nieuwe pagina.'), |
|
98 | 98 | InputField::make('slug') |
99 | 99 | ->translatable($this->model->availableLocales()) |
100 | 100 | ->validation($this->model->id |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | { |
40 | 40 | parent::__construct($registration); |
41 | 41 | |
42 | - $this->uniqueSlug = UniqueSlug::make(new PageTranslation)->slugResolver(function ($value) { |
|
42 | + $this->uniqueSlug = UniqueSlug::make(new PageTranslation)->slugResolver(function($value) { |
|
43 | 43 | return str_slug_slashed($value); |
44 | 44 | }); |
45 | 45 | } |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | { |
64 | 64 | $permission = 'update-page'; |
65 | 65 | |
66 | - if (in_array($verb, ['index','show'])) { |
|
66 | + if (in_array($verb, ['index', 'show'])) { |
|
67 | 67 | $permission = 'view-page'; |
68 | - } elseif (in_array($verb, ['create','store'])) { |
|
68 | + } elseif (in_array($verb, ['create', 'store'])) { |
|
69 | 69 | $permission = 'create-page'; |
70 | 70 | } elseif (in_array($verb, ['delete'])) { |
71 | 71 | $permission = 'delete-page'; |
72 | 72 | } |
73 | 73 | |
74 | - if (! auth()->guard('chief')->user()->hasPermissionTo($permission)) { |
|
74 | + if (!auth()->guard('chief')->user()->hasPermissionTo($permission)) { |
|
75 | 75 | throw NotAllowedManagerRoute::notAllowedPermission($permission, $this); |
76 | 76 | } |
77 | 77 | } |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | InputField::make('slug') |
99 | 99 | ->translatable($this->model->availableLocales()) |
100 | 100 | ->validation($this->model->id |
101 | - ? 'required-fallback-locale|unique:page_translations,slug,' . $this->model->id . ',page_id' |
|
101 | + ? 'required-fallback-locale|unique:page_translations,slug,'.$this->model->id.',page_id' |
|
102 | 102 | : 'required-fallback-locale|unique:page_translations,slug', [], [ |
103 | 103 | 'trans.'.config('app.fallback_locale', 'nl').'.slug' => 'slug' |
104 | 104 | ]) |
105 | 105 | ->label('Link') |
106 | 106 | ->description('De unieke url verwijzing naar deze pagina.') |
107 | - ->prepend(collect($this->model->availableLocales())->mapWithKeys(function ($locale) { |
|
107 | + ->prepend(collect($this->model->availableLocales())->mapWithKeys(function($locale) { |
|
108 | 108 | return [$locale => url($this->model->baseUrlSegment($locale)).'/']; |
109 | 109 | })->all()), |
110 | 110 | InputField::make('seo_title') |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | public function fieldArrangement($key = null): FieldArrangement |
141 | 141 | { |
142 | 142 | if ($key == 'create') { |
143 | - return new FieldArrangement($this->fields()->filterBy(function ($field) { |
|
143 | + return new FieldArrangement($this->fields()->filterBy(function($field) { |
|
144 | 144 | return $field->key == 'title'; |
145 | 145 | })); |
146 | 146 | } |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | if ($this->model->id) { |
160 | 160 | return parent::details() |
161 | 161 | ->set('title', $this->model->title) |
162 | - ->set('intro', 'laatst aangepast op ' . $this->model->updated_at->format('d/m/Y H:i')) |
|
163 | - ->set('context', '<span class="inline-s">' . $this->assistant('publish')->publicationStatusAsLabel() . '</span>'); |
|
162 | + ->set('intro', 'laatst aangepast op '.$this->model->updated_at->format('d/m/Y H:i')) |
|
163 | + ->set('context', '<span class="inline-s">'.$this->assistant('publish')->publicationStatusAsLabel().'</span>'); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return parent::details(); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | public function saveFields(): Manager |
170 | 170 | { |
171 | 171 | // Store the morph_key upon creation |
172 | - if (! $this->model->morph_key) { |
|
172 | + if (!$this->model->morph_key) { |
|
173 | 173 | $this->model->morph_key = $this->model->morphKey(); |
174 | 174 | } |
175 | 175 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | if (is_array_empty($translation)) { |
209 | 209 | |
210 | 210 | // Nullify all values |
211 | - $trans[$locale] = array_map(function ($value) { |
|
211 | + $trans[$locale] = array_map(function($value) { |
|
212 | 212 | return null; |
213 | 213 | }, $translation); |
214 | 214 | continue; |
@@ -19,7 +19,7 @@ |
||
19 | 19 | |
20 | 20 | public function apply($value = null): Closure |
21 | 21 | { |
22 | - return function ($query) use ($value) { |
|
22 | + return function($query) use ($value) { |
|
23 | 23 | if ($value == 'all') { |
24 | 24 | return $query; |
25 | 25 | } |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | |
38 | 38 | // Set required paths |
39 | 39 | $this->dirs = ['base' => $this->settings['base_path'] ?? base_path()]; |
40 | - $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'] .'/'. config('thinktomorrow.chief.domain.path', 'src'); |
|
41 | - $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'] . '/resources/views'; |
|
42 | - $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'] . '/app/Http/Controllers'; |
|
43 | - $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'] . '/routes/web.php'; |
|
40 | + $this->dirs['model'] = $this->settings['model_path'] ?? $this->dirs['base'].'/'.config('thinktomorrow.chief.domain.path', 'src'); |
|
41 | + $this->dirs['views'] = $this->settings['views_path'] ?? $this->dirs['base'].'/resources/views'; |
|
42 | + $this->dirs['controller'] = $this->settings['controller_path'] ?? $this->dirs['base'].'/app/Http/Controllers'; |
|
43 | + $this->files['routes'] = $this->settings['routes_file'] ?? $this->dirs['base'].'/routes/web.php'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function handle() |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | private function publishModel() |
63 | 63 | { |
64 | 64 | $this->publishFile( |
65 | - __DIR__ . '/stubs/model.php.stub', |
|
66 | - $to = $this->dirs['model'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php', |
|
65 | + __DIR__.'/stubs/model.php.stub', |
|
66 | + $to = $this->dirs['model'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php', |
|
67 | 67 | 'model' |
68 | 68 | ); |
69 | 69 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | private function publishController() |
74 | 74 | { |
75 | 75 | $this->publishFile( |
76 | - __DIR__ . '/stubs/controller.php.stub', |
|
77 | - $to = $this->dirs['controller'] . '/' . ucfirst($this->plural) . '/' . ucfirst($this->singular) . '.php', |
|
76 | + __DIR__.'/stubs/controller.php.stub', |
|
77 | + $to = $this->dirs['controller'].'/'.ucfirst($this->plural).'/'.ucfirst($this->singular).'.php', |
|
78 | 78 | 'controller' |
79 | 79 | ); |
80 | 80 | } |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | private function modelTraits() |
114 | 114 | { |
115 | 115 | return [ |
116 | - '\\' . Publishable::class, |
|
117 | - '\\' . Sortable::class, |
|
116 | + '\\'.Publishable::class, |
|
117 | + '\\'.Sortable::class, |
|
118 | 118 | 'q' => 'Proceed.', |
119 | 119 | ]; |
120 | 120 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | protected function publishFile($from, $to, $type) |
130 | 130 | { |
131 | 131 | if ($this->filesystem->exists($to) && !$this->option('force')) { |
132 | - if (!$this->confirm('File [' . $to . '] already exists? Overwrite this file?')) { |
|
132 | + if (!$this->confirm('File ['.$to.'] already exists? Overwrite this file?')) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | $to = str_replace($this->dirs['base'], '', realpath($to)); |
170 | 170 | |
171 | - $this->line('<info>Copied ' . $type . '</info> <comment>[' . $from . ']</comment> <info>To</info> <comment>[' . $to . ']</comment>'); |
|
171 | + $this->line('<info>Copied '.$type.'</info> <comment>['.$from.']</comment> <info>To</info> <comment>['.$to.']</comment>'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | protected function replacePlaceholders($content) |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | private function generateImportStatements(): string |
188 | 188 | { |
189 | 189 | return collect(['\\'.Page::class]) |
190 | - ->map(function ($statement) { |
|
191 | - return 'use ' . $statement . ";\n "; |
|
190 | + ->map(function($statement) { |
|
191 | + return 'use '.$statement.";\n "; |
|
192 | 192 | })->implode(''); |
193 | 193 | } |
194 | 194 | |
195 | 195 | private function generateTraitStatements(): string |
196 | 196 | { |
197 | 197 | return collect($this->chosenTraits) |
198 | - ->map(function ($statement) { |
|
199 | - return 'use ' . $statement . ";\n "; |
|
198 | + ->map(function($statement) { |
|
199 | + return 'use '.$statement.";\n "; |
|
200 | 200 | })->implode(''); |
201 | 201 | } |
202 | 202 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | // We make an estimated guess based on the project name. At Think Tomorrow, we |
217 | 217 | // have a src folder which is PSR-4 namespaced by the project name itself. |
218 | - return str_replace('\\\\', '\\', ucfirst(config('thinktomorrow.chief.domain.namespace', 'App')).'\\'. ucfirst($this->plural)); |
|
218 | + return str_replace('\\\\', '\\', ucfirst(config('thinktomorrow.chief.domain.namespace', 'App')).'\\'.ucfirst($this->plural)); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | private function addToConfig($configKey, $value) |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | public function flatReferenceLabel(): string |
116 | 116 | { |
117 | 117 | if ($this->exists) { |
118 | - $status = ! $this->isPublished() ? ' [' . $this->statusAsPlainLabel().']' : null; |
|
118 | + $status = !$this->isPublished() ? ' ['.$this->statusAsPlainLabel().']' : null; |
|
119 | 119 | |
120 | - return $this->title ? $this->title . $status : ''; |
|
120 | + return $this->title ? $this->title.$status : ''; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | return ''; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | return ''; |
176 | 176 | } |
177 | 177 | |
178 | - $parameters = trim($this->baseUrlSegment($locale) . '/' . $slug, '/'); |
|
178 | + $parameters = trim($this->baseUrlSegment($locale).'/'.$slug, '/'); |
|
179 | 179 | |
180 | 180 | $routeName = Homepage::is($this) |
181 | 181 | ? config('thinktomorrow.chief.routes.pages-home', 'pages.home') |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | ]; |
239 | 239 | |
240 | 240 | foreach ($viewPaths as $viewPath) { |
241 | - if (! view()->exists($viewPath)) { |
|
241 | + if (!view()->exists($viewPath)) { |
|
242 | 242 | continue; |
243 | 243 | } |
244 | 244 |
@@ -57,23 +57,23 @@ discard block |
||
57 | 57 | private function presentRawValueForParent(ActsAsParent $parent): string |
58 | 58 | { |
59 | 59 | $viewPaths = [ |
60 | - 'front.modules.'. $parent->viewKey().'.'.$this->viewKey(), |
|
60 | + 'front.modules.'.$parent->viewKey().'.'.$this->viewKey(), |
|
61 | 61 | 'front.modules.'.$this->viewKey(), |
62 | - 'modules.'. $parent->viewKey().'.'.$this->viewKey(), |
|
62 | + 'modules.'.$parent->viewKey().'.'.$this->viewKey(), |
|
63 | 63 | 'modules.'.$this->viewKey(), |
64 | 64 | ]; |
65 | 65 | |
66 | 66 | // In case the collection set is made out of pages, we'll also allow to use the |
67 | 67 | // generic collection page view for these sets as well as a fallback view |
68 | 68 | if ($this->first() instanceof PresentForParent) { |
69 | - $viewPaths[] = 'front.modules.'. $parent->viewKey().'.'.$this->first()->viewKey(); |
|
70 | - $viewPaths[] = 'front.modules.'. $this->first()->viewKey(); |
|
71 | - $viewPaths[] = 'modules.'. $parent->viewKey().'.'.$this->first()->viewKey(); |
|
72 | - $viewPaths[] = 'modules.'. $this->first()->viewKey(); |
|
69 | + $viewPaths[] = 'front.modules.'.$parent->viewKey().'.'.$this->first()->viewKey(); |
|
70 | + $viewPaths[] = 'front.modules.'.$this->first()->viewKey(); |
|
71 | + $viewPaths[] = 'modules.'.$parent->viewKey().'.'.$this->first()->viewKey(); |
|
72 | + $viewPaths[] = 'modules.'.$this->first()->viewKey(); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | foreach ($viewPaths as $viewPath) { |
76 | - if (! view()->exists($viewPath)) { |
|
76 | + if (!view()->exists($viewPath)) { |
|
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | // If no view has been created for this page collection, we try once again to fetch the content value if any. This will silently fail |
90 | 90 | // if no content value is present. We don't consider the 'content' attribute to be a default as we do for module. |
91 | - return $this->map(function ($item) use ($parent) { |
|
91 | + return $this->map(function($item) use ($parent) { |
|
92 | 92 | return ($item instanceof PresentForParent) |
93 | 93 | ? $item->presentForParent($parent) |
94 | 94 | : ($item->content ?? ''); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | { |
123 | 123 | $currentPage = $currentPage ?? request()->get('page', 1); |
124 | 124 | $path = request()->path(); |
125 | - $items = array_slice($this->all(), ($currentPage - 1) * $perPage); |
|
125 | + $items = array_slice($this->all(), ($currentPage-1) * $perPage); |
|
126 | 126 | |
127 | 127 | return (new \Illuminate\Pagination\Paginator($items, $perPage, $currentPage))->setPath($path); |
128 | 128 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | { |
140 | 140 | $currentPage = $currentPage ?? request()->get('page', 1); |
141 | 141 | $path = request()->path(); |
142 | - $items = array_slice($this->all(), ($currentPage - 1) * $perPage, $perPage); |
|
142 | + $items = array_slice($this->all(), ($currentPage-1) * $perPage, $perPage); |
|
143 | 143 | |
144 | 144 | return (new \Illuminate\Pagination\LengthAwarePaginator($items, $this->count(), $perPage, $currentPage))->setPath($path); |
145 | 145 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | // Constraints |
36 | 36 | if (!isset($values['action'])) { |
37 | - throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: ' . print_r($values, true)); |
|
37 | + throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: '.print_r($values, true)); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return new static( |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | { |
50 | 50 | $sets = config('thinktomorrow.chief.sets', []); |
51 | 51 | |
52 | - return collect($sets)->map(function ($set, $key) { |
|
52 | + return collect($sets)->map(function($set, $key) { |
|
53 | 53 | return SetReference::fromArray($key, $set); |
54 | 54 | }); |
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function find($key): ?SetReference |
58 | 58 | { |
59 | - return static::all()->filter(function ($ref) use ($key) { |
|
59 | + return static::all()->filter(function($ref) use ($key) { |
|
60 | 60 | return $ref->key() == $key; |
61 | 61 | })->first(); |
62 | 62 | } |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | |
74 | 74 | $this->validateAction($class, $method); |
75 | 75 | |
76 | - $result = call_user_func_array([app($class),$method], $this->parameters); |
|
76 | + $result = call_user_func_array([app($class), $method], $this->parameters); |
|
77 | 77 | |
78 | - if (! $result instanceof Set && $result instanceof Collection) { |
|
78 | + if (!$result instanceof Set && $result instanceof Collection) { |
|
79 | 79 | return new Set($result->all(), $this->key); |
80 | 80 | } |
81 | 81 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | private static function validateAction($class, $method) |
109 | 109 | { |
110 | - if (! class_exists($class)) { |
|
110 | + if (!class_exists($class)) { |
|
111 | 111 | throw new \InvalidArgumentException('The class ['.$class.'] isn\'t a valid class reference or does not exist in the chief-settings.sets config entry.'); |
112 | 112 | } |
113 | 113 |