@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Thinktomorrow\Chief\Fields\Types; |
4 | 4 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | return $request->input($this->dottedName()); |
21 | 21 | } |
22 | 22 | |
23 | - public function save( Request $request) |
|
23 | + public function save(Request $request) |
|
24 | 24 | { |
25 | 25 | |
26 | 26 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $images = []; |
31 | 31 | $locale = $locale ?? app()->getLocale(); |
32 | 32 | |
33 | - $assets = $model->assetRelation->where('pivot.type', $this->key())->filter(function ($asset) use ($locale) { |
|
33 | + $assets = $model->assetRelation->where('pivot.type', $this->key())->filter(function($asset) use ($locale) { |
|
34 | 34 | return $asset->pivot->locale == $locale; |
35 | 35 | })->sortBy('pivot.order'); |
36 | 36 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Thinktomorrow\Chief\Fields\Types; |
4 | 4 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | return $this; |
43 | 43 | } |
44 | 44 | |
45 | - return 'files['. ($this->values['name'] ?? $this->key()).']'; |
|
45 | + return 'files['.($this->values['name'] ?? $this->key()).']'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function sluggifyName() |
@@ -4,23 +4,23 @@ discard block |
||
4 | 4 | |
5 | 5 | class FieldType |
6 | 6 | { |
7 | - const INPUT = 'input'; // oneliner text (input) |
|
8 | - const TEXT = 'text'; // Plain text (textarea) |
|
7 | + const INPUT = 'input'; // oneliner text (input) |
|
8 | + const TEXT = 'text'; // Plain text (textarea) |
|
9 | 9 | const NUMBER = 'number'; // number |
10 | 10 | const RANGE = 'range'; // range slider |
11 | - const DATE = 'date'; // Timestamp input |
|
12 | - const PHONENUMBER = 'phonenumber'; // Timestamp input |
|
13 | - const HTML = 'html'; // Html text (wysiwyg) |
|
14 | - const SELECT = 'select'; // Select options |
|
11 | + const DATE = 'date'; // Timestamp input |
|
12 | + const PHONENUMBER = 'phonenumber'; // Timestamp input |
|
13 | + const HTML = 'html'; // Html text (wysiwyg) |
|
14 | + const SELECT = 'select'; // Select options |
|
15 | 15 | |
16 | - const MEDIA = 'media'; // media file (basic file uploader) |
|
17 | - const IMAGE = 'image'; // image (regular uploader) |
|
18 | - const DOCUMENT = 'document'; // only documents (basic file uploader) |
|
19 | - const SLIMIMAGE = 'slimimage'; // image (slim uploader) |
|
16 | + const MEDIA = 'media'; // media file (basic file uploader) |
|
17 | + const IMAGE = 'image'; // image (regular uploader) |
|
18 | + const DOCUMENT = 'document'; // only documents (basic file uploader) |
|
19 | + const SLIMIMAGE = 'slimimage'; // image (slim uploader) |
|
20 | 20 | |
21 | - const RADIO = 'radio'; // radio select |
|
22 | - const CHECKBOX = 'checkbox'; // checkbox select |
|
23 | - const PAGEBUILDER = 'pagebuilder'; // the most special field there is... |
|
21 | + const RADIO = 'radio'; // radio select |
|
22 | + const CHECKBOX = 'checkbox'; // checkbox select |
|
23 | + const PAGEBUILDER = 'pagebuilder'; // the most special field there is... |
|
24 | 24 | |
25 | 25 | /** @var string */ |
26 | 26 | private $type; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | public static function fromString(string $type): self |
41 | 41 | { |
42 | - $class = 'Thinktomorrow\Chief\Fields\Types\\' . ucfirst($type . 'Field'); |
|
42 | + $class = 'Thinktomorrow\Chief\Fields\Types\\'.ucfirst($type.'Field'); |
|
43 | 43 | |
44 | 44 | return new $class(new static($type)); |
45 | 45 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Thinktomorrow\Chief\Fields\Types; |
4 | 4 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | public function optional(): bool |
76 | 76 | { |
77 | - return ! $this->required(); |
|
77 | + return !$this->required(); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public function name(string $name = null) |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | public function dottedName(): string |
92 | 92 | { |
93 | - return str_replace(['[',']'], ['.',''], $this->name()); |
|
93 | + return str_replace(['[', ']'], ['.', ''], $this->name()); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | public function translatable(array $locales = []) |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | private function defaultValueResolver(): callable |
162 | 162 | { |
163 | - return function (Model $model, $locale) { |
|
163 | + return function(Model $model, $locale) { |
|
164 | 164 | if ($this->isTranslatable() && $locale) { |
165 | 165 | return $model->getTranslationFor($this->column(), $locale); |
166 | 166 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | if (!in_array($name, ['label', 'key', 'description', 'column', 'name', 'prepend', 'append'])) { |
238 | - throw new \InvalidArgumentException('Cannot set value by ['. $name .'].'); |
|
238 | + throw new \InvalidArgumentException('Cannot set value by ['.$name.'].'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | $this->values[$name] = $arguments[0]; |
@@ -36,7 +36,4 @@ |
||
36 | 36 | |
37 | 37 | private function getMedia(HasAsset $model, $locale = null) |
38 | 38 | { |
39 | - return $model->assets($this->key(), $locale)->all(); |
|
40 | - } |
|
41 | ->>>>>>> 0b857885b773fe2d5321aefa1f512733906e1067 |
|
42 | -} |
|
39 | + return $model->assets($this->key(), $locale |
|
43 | 40 | \ No newline at end of file |
@@ -36,7 +36,4 @@ |
||
36 | 36 | |
37 | 37 | private function getMedia(HasAsset $model, $locale = null) |
38 | 38 | { |
39 | - return $model->assets($this->key(), $locale)->all(); |
|
40 | - } |
|
41 | ->>>>>>> 0b857885b773fe2d5321aefa1f512733906e1067 |
|
42 | -} |
|
39 | + return $model->assets($this->key(), $locale |
|
43 | 40 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | { |
9 | 9 | return new static(new FieldType(FieldType::DOCUMENT), $key); |
10 | 10 | } |
11 | -<<<<<<< HEAD |
|
11 | +<< << <<< HEAD |
|
12 | 12 | ======= |
13 | 13 | |
14 | 14 | public function multiple($flag = true) |
@@ -36,7 +36,4 @@ discard block |
||
36 | 36 | |
37 | 37 | private function getMedia(HasAsset $model, $locale = null) |
38 | 38 | { |
39 | - return $model->assets($this->key(), $locale)->all(); |
|
40 | - } |
|
41 | ->>>>>>> 0b857885b773fe2d5321aefa1f512733906e1067 |
|
42 | -} |
|
39 | + return $model->assets($this->key(), $locale |
|
43 | 40 | \ No newline at end of file |
@@ -36,7 +36,4 @@ |
||
36 | 36 | |
37 | 37 | private function getMedia(HasAsset $model, $locale = null) |
38 | 38 | { |
39 | - return $model->assets($this->key(), $locale)->all(); |
|
40 | - } |
|
41 | ->>>>>>> 0b857885b773fe2d5321aefa1f512733906e1067 |
|
42 | -} |
|
39 | + return $model->assets($this->key(), $locale |
|
43 | 40 | \ No newline at end of file |
@@ -36,7 +36,4 @@ |
||
36 | 36 | |
37 | 37 | private function getMedia(HasAsset $model, $locale = null) |
38 | 38 | { |
39 | - return $model->assets($this->key(), $locale)->all(); |
|
40 | - } |
|
41 | ->>>>>>> 0b857885b773fe2d5321aefa1f512733906e1067 |
|
42 | -} |
|
39 | + return $model->assets($this->key(), $locale |
|
43 | 40 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Thinktomorrow\Chief\Fields\Types; |
4 | 4 | |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | $images = []; |
17 | 17 | $locale = $locale ?? app()->getLocale(); |
18 | 18 | |
19 | - $assets = $model->assetRelation->where('pivot.type', $this->key())->filter(function ($asset) use ($locale) { |
|
19 | + $assets = $model->assetRelation->where('pivot.type', $this->key())->filter(function($asset) use ($locale) { |
|
20 | 20 | return $asset->pivot->locale == $locale; |
21 | 21 | })->sortBy('pivot.order'); |
22 | 22 |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | |
124 | 124 | public function offsetSet($offset, $value) |
125 | 125 | { |
126 | - if (! $value instanceof AbstractField) { |
|
127 | - throw new \InvalidArgumentException('Passed value must be of type ' . AbstractField::class); |
|
126 | + if (!$value instanceof AbstractField) { |
|
127 | + throw new \InvalidArgumentException('Passed value must be of type '.AbstractField::class); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | $this->fields[$offset] = $value; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | private function validateFields(array $fields) |
155 | 155 | { |
156 | - array_map(function (AbstractField $field) { |
|
156 | + array_map(function(AbstractField $field) { |
|
157 | 157 | }, $fields); |
158 | 158 | } |
159 | 159 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | public function validate(Fields $fields, array $data) |
27 | 27 | { |
28 | - foreach($fields as $field){ |
|
28 | + foreach ($fields as $field) { |
|
29 | 29 | $this->validator($field, $data)->validate(); |
30 | 30 | } |
31 | 31 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | // } |
41 | 41 | |
42 | 42 | // Custom set methods - default is the generic setField() method. |
43 | - $methodName = 'set'. ucfirst(Str::camel($field->key())) . 'Field'; |
|
43 | + $methodName = 'set'.ucfirst(Str::camel($field->key())).'Field'; |
|
44 | 44 | (method_exists($this, $methodName)) |
45 | 45 | ? $this->$methodName($field, $request) |
46 | 46 | : $this->setField($field, $request); |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | |
57 | 57 | protected function detectCustomSaveMethods(AbstractField $field): bool |
58 | 58 | { |
59 | - $methodByKey = 'save'. ucfirst(Str::camel($field->key())) . 'Field'; |
|
60 | - $methodByType = 'save'. ucfirst(Str::camel($field->type()->get())) . 'Field'; |
|
59 | + $methodByKey = 'save'.ucfirst(Str::camel($field->key())).'Field'; |
|
60 | + $methodByType = 'save'.ucfirst(Str::camel($field->type()->get())).'Field'; |
|
61 | 61 | |
62 | 62 | // Custom save method on assistant |
63 | 63 | foreach ($this->assistants() as $assistant) { |