@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | return $this->indexPagination($builder); |
89 | 89 | } |
90 | 90 | |
91 | - return $builder->get()->map(function ($model) { |
|
91 | + return $builder->get()->map(function($model) { |
|
92 | 92 | return (new static($this->registration))->manage($model); |
93 | 93 | }); |
94 | 94 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $paginator = $builder->paginate($this->pageCount); |
118 | 118 | |
119 | - $modifiedCollection = $builder->paginate($this->pageCount)->getCollection()->transform(function ($model) { |
|
119 | + $modifiedCollection = $builder->paginate($this->pageCount)->getCollection()->transform(function($model) { |
|
120 | 120 | return (new static($this->registration))->manage($model); |
121 | 121 | }); |
122 | 122 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | public function editFields(): Fields |
234 | 234 | { |
235 | - return $this->fieldsWithAssistantFields()->map(function(Field $field){ |
|
235 | + return $this->fieldsWithAssistantFields()->map(function(Field $field) { |
|
236 | 236 | return $field->model($this->model); |
237 | 237 | }); |
238 | 238 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | static::$bootedTraitMethods[$baseMethod] = []; |
326 | 326 | |
327 | 327 | foreach (class_uses_recursive($class) as $trait) { |
328 | - $method = class_basename($trait) . ucfirst($baseMethod); |
|
328 | + $method = class_basename($trait).ucfirst($baseMethod); |
|
329 | 329 | |
330 | 330 | if (method_exists($class, $method) && !in_array($method, static::$bootedTraitMethods[$baseMethod])) { |
331 | 331 | static::$bootedTraitMethods[$baseMethod][] = lcfirst($method); |
@@ -51,8 +51,8 @@ |
||
51 | 51 | |
52 | 52 | public function editFields(): Fields |
53 | 53 | { |
54 | - return $this->fields()->map(function(Field $field){ |
|
55 | - return $field->valueResolver(function($model = null, $locale = null, $field){ |
|
54 | + return $this->fields()->map(function(Field $field) { |
|
55 | + return $field->valueResolver(function($model = null, $locale = null, $field) { |
|
56 | 56 | return $this->settings->get($field->getKey(), $locale); |
57 | 57 | }); |
58 | 58 | }); |
@@ -8,7 +8,7 @@ |
||
8 | 8 | |
9 | 9 | public function tagged($tag): bool |
10 | 10 | { |
11 | - $tags = (array) $tag; |
|
11 | + $tags = (array)$tag; |
|
12 | 12 | |
13 | 13 | return count(array_intersect($this->tags, $tags)) > 0; |
14 | 14 | } |
@@ -23,9 +23,9 @@ |
||
23 | 23 | |
24 | 24 | $field = $manager->fields()[($reference->hasFragmentKey() ? $reference->getFragmentKey() : $reference->getFieldKey())]; |
25 | 25 | |
26 | - if($reference->hasFragmentKey()) { |
|
27 | - if(!$field instanceof FragmentField) { |
|
28 | - throw new \RuntimeException('Field ' . $field->getKey() . ' was expected to be a fragmentfield but its not.'); |
|
26 | + if ($reference->hasFragmentKey()) { |
|
27 | + if (!$field instanceof FragmentField) { |
|
28 | + throw new \RuntimeException('Field '.$field->getKey().' was expected to be a fragmentfield but its not.'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | $firstFragment = $field->getFragments()[0]; |
@@ -21,19 +21,19 @@ |
||
21 | 21 | { |
22 | 22 | return (new static(new FieldType(FieldType::FILE), $key)) |
23 | 23 | ->locales([config('app.fallback_locale', 'nl')]) |
24 | - ->valueResolver(function($model = null, $locale = null, FileField $field){ |
|
24 | + ->valueResolver(function($model = null, $locale = null, FileField $field) { |
|
25 | 25 | return $field->getMedia($model, $locale); |
26 | 26 | }); |
27 | 27 | } |
28 | 28 | |
29 | 29 | public function getMedia(HasAsset $model = null, ?string $locale = null) |
30 | 30 | { |
31 | - if(!$model) return []; |
|
31 | + if (!$model) return []; |
|
32 | 32 | |
33 | 33 | $files = []; |
34 | 34 | $locale = $locale ?? app()->getLocale(); |
35 | 35 | |
36 | - $assets = $model->assetRelation->where('pivot.type', $this->getKey())->filter(function ($asset) use ($locale) { |
|
36 | + $assets = $model->assetRelation->where('pivot.type', $this->getKey())->filter(function($asset) use ($locale) { |
|
37 | 37 | return $asset->pivot->locale == $locale; |
38 | 38 | })->sortBy('pivot.order'); |
39 | 39 |
@@ -28,7 +28,9 @@ |
||
28 | 28 | |
29 | 29 | public function getMedia(HasAsset $model = null, ?string $locale = null) |
30 | 30 | { |
31 | - if(!$model) return []; |
|
31 | + if(!$model) { |
|
32 | + return []; |
|
33 | + } |
|
32 | 34 | |
33 | 35 | $files = []; |
34 | 36 | $locale = $locale ?? app()->getLocale(); |
@@ -6,19 +6,19 @@ |
||
6 | 6 | |
7 | 7 | class FieldType |
8 | 8 | { |
9 | - const INPUT = 'input'; // oneliner text (input) |
|
10 | - const TEXT = 'text'; // Plain text (textarea) |
|
9 | + const INPUT = 'input'; // oneliner text (input) |
|
10 | + const TEXT = 'text'; // Plain text (textarea) |
|
11 | 11 | const NUMBER = 'number'; // number |
12 | 12 | const RANGE = 'range'; // range slider |
13 | - const DATE = 'date'; // Timestamp input |
|
14 | - const PHONENUMBER = 'phonenumber'; // Timestamp input |
|
15 | - const HTML = 'html'; // Html text (wysiwyg) |
|
16 | - const SELECT = 'select'; // Select options |
|
17 | - const FILE = 'file'; // regular file |
|
18 | - const IMAGE = 'image'; // image (slim uploader) |
|
19 | - const RADIO = 'radio'; // radio select |
|
20 | - const CHECKBOX = 'checkbox'; // checkbox select |
|
21 | - const PAGEBUILDER = 'pagebuilder'; // the most special field there is... |
|
13 | + const DATE = 'date'; // Timestamp input |
|
14 | + const PHONENUMBER = 'phonenumber'; // Timestamp input |
|
15 | + const HTML = 'html'; // Html text (wysiwyg) |
|
16 | + const SELECT = 'select'; // Select options |
|
17 | + const FILE = 'file'; // regular file |
|
18 | + const IMAGE = 'image'; // image (slim uploader) |
|
19 | + const RADIO = 'radio'; // radio select |
|
20 | + const CHECKBOX = 'checkbox'; // checkbox select |
|
21 | + const PAGEBUILDER = 'pagebuilder'; // the most special field there is... |
|
22 | 22 | const FRAGMENT = 'fragment'; |
23 | 23 | |
24 | 24 | /** @var string */ |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | */ |
264 | 264 | private function defaultEloquentValueResolver(): \Closure |
265 | 265 | { |
266 | - return function (Model $model = null, $locale = null) { |
|
266 | + return function(Model $model = null, $locale = null) { |
|
267 | 267 | |
268 | - if($this->value) return $this->value; |
|
268 | + if ($this->value) return $this->value; |
|
269 | 269 | |
270 | 270 | if (!$model) { |
271 | 271 | return $this->default; |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | return $this->isLocalized() |
421 | 421 | ? 'chief::back._formgroups.fieldgroup_translatable' |
422 | - : 'chief::back._fields.' . $this->type->get(); |
|
422 | + : 'chief::back._fields.'.$this->type->get(); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | public function viewData(array $viewData = []): Field |
@@ -435,6 +435,6 @@ discard block |
||
435 | 435 | 'model' => $this->getModel(), |
436 | 436 | 'field' => $this, |
437 | 437 | 'key' => $this->getKey(), |
438 | - ],$this->viewData); |
|
438 | + ], $this->viewData); |
|
439 | 439 | } |
440 | 440 | } |
@@ -265,7 +265,9 @@ |
||
265 | 265 | { |
266 | 266 | return function (Model $model = null, $locale = null) { |
267 | 267 | |
268 | - if($this->value) return $this->value; |
|
268 | + if($this->value) { |
|
269 | + return $this->value; |
|
270 | + } |
|
269 | 271 | |
270 | 272 | if (!$model) { |
271 | 273 | return $this->default; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | return (new static(new FieldType(FieldType::IMAGE), $key)) |
22 | 22 | ->locales([config('app.fallback_locale', 'nl')]) |
23 | - ->valueResolver(function($model = null, $locale = null, ImageField $field){ |
|
23 | + ->valueResolver(function($model = null, $locale = null, ImageField $field) { |
|
24 | 24 | return $field->getMedia($model, $locale); |
25 | 25 | }); |
26 | 26 | } |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | |
33 | 33 | public function getMedia(HasAsset $model = null, ?string $locale = null) |
34 | 34 | { |
35 | - if(!$model) return []; |
|
35 | + if (!$model) return []; |
|
36 | 36 | |
37 | 37 | $images = []; |
38 | 38 | $locale = $locale ?? app()->getLocale(); |
39 | 39 | |
40 | - $assets = $model->assetRelation->where('pivot.type', $this->getKey())->filter(function ($asset) use ($locale) { |
|
40 | + $assets = $model->assetRelation->where('pivot.type', $this->getKey())->filter(function($asset) use ($locale) { |
|
41 | 41 | return $asset->pivot->locale == $locale; |
42 | 42 | })->sortBy('pivot.order'); |
43 | 43 |
@@ -32,7 +32,9 @@ |
||
32 | 32 | |
33 | 33 | public function getMedia(HasAsset $model = null, ?string $locale = null) |
34 | 34 | { |
35 | - if(!$model) return []; |
|
35 | + if(!$model) { |
|
36 | + return []; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $images = []; |
38 | 40 | $locale = $locale ?? app()->getLocale(); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | $clonedFields = []; |
65 | 65 | |
66 | - foreach($this->fields as $field){ |
|
66 | + foreach ($this->fields as $field) { |
|
67 | 67 | $clonedFields[] = clone $field; |
68 | 68 | } |
69 | 69 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | continue; |
93 | 93 | } |
94 | 94 | |
95 | - $method = 'get' . ucfirst($key); |
|
95 | + $method = 'get'.ucfirst($key); |
|
96 | 96 | |
97 | 97 | // Reject from list if value does not match expected one |
98 | 98 | if ($value && $value == $field->$method()) { |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | |
109 | 109 | public function render(): string |
110 | 110 | { |
111 | - return array_reduce($this->fields, function(string $carry, Field $field){ |
|
112 | - return $carry . $field->render(); |
|
111 | + return array_reduce($this->fields, function(string $carry, Field $field) { |
|
112 | + return $carry.$field->render(); |
|
113 | 113 | }, ''); |
114 | 114 | } |
115 | 115 | |
116 | 116 | public function keyed($key): Fields |
117 | 117 | { |
118 | - $keys = (array) $key; |
|
118 | + $keys = (array)$key; |
|
119 | 119 | |
120 | 120 | return new static(array_filter($this->fields, function(Field $field) use($keys){ |
121 | 121 | return in_array($field->getKey(), $keys); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | public function untagged(): Fields |
133 | 133 | { |
134 | - return new static(array_filter($this->fields, function(Field $field){ |
|
134 | + return new static(array_filter($this->fields, function(Field $field) { |
|
135 | 135 | return $field->untagged(); |
136 | 136 | })); |
137 | 137 | } |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | |
173 | 173 | public function offsetGet($offset) |
174 | 174 | { |
175 | - if(!isset($this->fields[$offset])){ |
|
176 | - throw new \RuntimeException('No field found by key [' . $offset . ']'); |
|
175 | + if (!isset($this->fields[$offset])) { |
|
176 | + throw new \RuntimeException('No field found by key ['.$offset.']'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | return $this->fields[$offset]; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | public function offsetSet($offset, $value) |
183 | 183 | { |
184 | 184 | if (!$value instanceof Field) { |
185 | - throw new \InvalidArgumentException('Passed value must be of type ' . Field::class); |
|
185 | + throw new \InvalidArgumentException('Passed value must be of type '.Field::class); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | $this->fields[$offset] = $value; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | private function validateFields(array $fields) |
214 | 214 | { |
215 | - array_map(function (Field $field) { |
|
215 | + array_map(function(Field $field) { |
|
216 | 216 | }, $fields); |
217 | 217 | } |
218 | 218 |