@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | trait HasPageSelect |
8 | 8 | { |
9 | - public function convertPagefieldvaluesToLinks($value, $locale = null){ |
|
9 | + public function convertPagefieldvaluesToLinks($value, $locale = null) { |
|
10 | 10 | |
11 | 11 | return FlatReferenceFactory::fromString($value)->instance()->url($locale ?? app()->getLocale()); |
12 | 12 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | |
4 | 4 | namespace Thinktomorrow\Chief\Fields\Types; |
5 | 5 | |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | |
20 | 20 | public function options(array $morphKeys = []) |
21 | 21 | { |
22 | - if( ! empty($morphKeys)) { |
|
23 | - $morphKeys = collect($morphKeys)->map(function($key){ |
|
22 | + if (!empty($morphKeys)) { |
|
23 | + $morphKeys = collect($morphKeys)->map(function($key) { |
|
24 | 24 | return (new $key)->getMorphClass(); |
25 | 25 | }); |
26 | 26 | |
27 | 27 | $pages = UrlHelper::modelsByType($morphKeys->toArray())->get(); |
28 | 28 | $pages = FlatReferencePresenter::toGroupedSelectValues($pages)->toArray(); |
29 | - } else { |
|
29 | + }else { |
|
30 | 30 | $pages = UrlHelper::allModelsWithoutSelf($this->model); |
31 | 31 | } |
32 | 32 |
@@ -6,22 +6,22 @@ |
||
6 | 6 | |
7 | 7 | class FieldType |
8 | 8 | { |
9 | - const INPUT = 'input'; // oneliner text (input) |
|
10 | - const TEXT = 'text'; // Plain text (textarea) |
|
11 | - const NUMBER = 'number'; // number |
|
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 |
|
9 | + const INPUT = 'input'; // oneliner text (input) |
|
10 | + const TEXT = 'text'; // Plain text (textarea) |
|
11 | + const NUMBER = 'number'; // number |
|
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 | 17 | //const MEDIA = 'media'; // media file |
18 | - const FILE = 'file'; // regular file |
|
19 | - const IMAGE = 'image'; // image (slim uploader) |
|
20 | - const DOCUMENT = 'document'; // documents |
|
21 | - const RADIO = 'radio'; // radio select |
|
22 | - const CHECKBOX = 'checkbox'; // checkbox select |
|
23 | - const PAGEBUILDER = 'pagebuilder'; // the most special field there is... |
|
24 | - const PAGE = 'page'; // select a page (also a special field) |
|
18 | + const FILE = 'file'; // regular file |
|
19 | + const IMAGE = 'image'; // image (slim uploader) |
|
20 | + const DOCUMENT = 'document'; // documents |
|
21 | + const RADIO = 'radio'; // radio select |
|
22 | + const CHECKBOX = 'checkbox'; // checkbox select |
|
23 | + const PAGEBUILDER = 'pagebuilder'; // the most special field there is... |
|
24 | + const PAGE = 'page'; // select a page (also a special field) |
|
25 | 25 | |
26 | 26 | /** @var string */ |
27 | 27 | private $type; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | public static function models(bool $onlySingles = false, Model $ignoredModel = null, $online = true) |
65 | 65 | { |
66 | - $models = chiefMemoize('all-online-models', function () use ($onlySingles, $online) { |
|
66 | + $models = chiefMemoize('all-online-models', function() use ($onlySingles, $online) { |
|
67 | 67 | $builder = UrlRecord::whereNull('redirect_id') |
68 | 68 | ->select('model_type', 'model_id') |
69 | 69 | ->groupBy('model_type', 'model_id'); |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | $builder->where('model_type', 'singles'); |
73 | 73 | } |
74 | 74 | |
75 | - return $builder->get()->mapToGroups(function ($record) { |
|
75 | + return $builder->get()->mapToGroups(function($record) { |
|
76 | 76 | return [$record->model_type => $record->model_id]; |
77 | - })->map(function ($record, $key) { |
|
77 | + })->map(function($record, $key) { |
|
78 | 78 | return Morphables::instance($key)->find($record->toArray()); |
79 | - })->map->reject(function ($model) use ($online) { |
|
79 | + })->map->reject(function($model) use ($online) { |
|
80 | 80 | if ($online) { |
81 | 81 | return is_null($model) || !$model->isPublished(); |
82 | 82 | } // Invalid references to archived or removed models where url record still exists. |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | }, [$onlySingles]); |
87 | 87 | |
88 | 88 | if ($ignoredModel) { |
89 | - $models = $models->reject(function ($model) use ($ignoredModel) { |
|
89 | + $models = $models->reject(function($model) use ($ignoredModel) { |
|
90 | 90 | return (get_class($model) === get_class($ignoredModel) && $model->id === $ignoredModel->id); |
91 | 91 | }); |
92 | 92 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | public static function modelsByType(array $types, Model $ignoredModel = null, $online = true) |
99 | 99 | { |
100 | - $models = chiefMemoize('all-online-models', function () use ($types, $online) { |
|
100 | + $models = chiefMemoize('all-online-models', function() use ($types, $online) { |
|
101 | 101 | $builder = UrlRecord::whereNull('redirect_id') |
102 | 102 | ->select('model_type', 'model_id') |
103 | 103 | ->groupBy('model_type', 'model_id'); |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | $builder->whereIn('model_type', $types); |
107 | 107 | } |
108 | 108 | |
109 | - return $builder->get()->mapToGroups(function ($record) { |
|
109 | + return $builder->get()->mapToGroups(function($record) { |
|
110 | 110 | return [$record->model_type => $record->model_id]; |
111 | - })->map(function ($record, $key) { |
|
111 | + })->map(function($record, $key) { |
|
112 | 112 | return Morphables::instance($key)->find($record->toArray()); |
113 | - })->map->reject(function ($model) use ($online) { |
|
113 | + })->map->reject(function($model) use ($online) { |
|
114 | 114 | if ($online) { |
115 | 115 | return is_null($model) || !$model->isPublished(); |
116 | 116 | } // Invalid references to archived or removed models where url record still exists. |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | }); |
121 | 121 | |
122 | 122 | if ($ignoredModel) { |
123 | - $models = $models->reject(function ($model) use ($ignoredModel) { |
|
123 | + $models = $models->reject(function($model) use ($ignoredModel) { |
|
124 | 124 | return (get_class($model) === get_class($ignoredModel) && $model->id === $ignoredModel->id); |
125 | 125 | }); |
126 | 126 | } |