@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ->performedOn($this->manager->existingModel()) |
60 | 60 | ->log('published'); |
61 | 61 | |
62 | - return redirect()->to($this->manager->route('edit'))->with('messages.success', $this->manager->details()->title . ' is online gezet.'); |
|
62 | + return redirect()->to($this->manager->route('edit'))->with('messages.success', $this->manager->details()->title.' is online gezet.'); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function unpublish() |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | ->performedOn($this->manager->existingModel()) |
74 | 74 | ->log('unpublished'); |
75 | 75 | |
76 | - return redirect()->to($this->manager->route('edit'))->with('messages.success', $this->manager->details()->title . ' is offline gehaald.'); |
|
76 | + return redirect()->to($this->manager->route('edit'))->with('messages.success', $this->manager->details()->title.' is offline gehaald.'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | public function findAll(): Collection |
80 | 80 | { |
81 | - return $this->manager->existingModel()->published()->get()->map(function ($model) { |
|
81 | + return $this->manager->existingModel()->published()->get()->map(function($model) { |
|
82 | 82 | return $this->managers->findByModel($model); |
83 | 83 | }); |
84 | 84 | } |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | $class = 'text-warning'; |
130 | 130 | } |
131 | 131 | |
132 | - $statusAsLabel = '<span class="' . $class . '">' . $label . '</span>'; |
|
132 | + $statusAsLabel = '<span class="'.$class.'">'.$label.'</span>'; |
|
133 | 133 | |
134 | 134 | if (!$plain && $this->hasPreviewUrl()) { |
135 | - $statusAsLabel = '<a href="' . $this->previewUrl() . '" target="_blank">' . $statusAsLabel . '</a>'; |
|
135 | + $statusAsLabel = '<a href="'.$this->previewUrl().'" target="_blank">'.$statusAsLabel.'</a>'; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return $statusAsLabel; |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | { |
59 | 59 | $permission = 'update-page'; |
60 | 60 | |
61 | - if (in_array($verb, ['index','show'])) { |
|
61 | + if (in_array($verb, ['index', 'show'])) { |
|
62 | 62 | $permission = 'view-page'; |
63 | - } elseif (in_array($verb, ['create','store'])) { |
|
63 | + } elseif (in_array($verb, ['create', 'store'])) { |
|
64 | 64 | $permission = 'create-page'; |
65 | 65 | } elseif (in_array($verb, ['delete'])) { |
66 | 66 | $permission = 'delete-page'; |
67 | 67 | } |
68 | 68 | |
69 | - if (! auth()->guard('chief')->user()->hasPermissionTo($permission)) { |
|
69 | + if (!auth()->guard('chief')->user()->hasPermissionTo($permission)) { |
|
70 | 70 | throw NotAllowedManagerRoute::notAllowedPermission($permission, $this); |
71 | 71 | } |
72 | 72 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | public function fieldArrangement($key = null): FieldArrangement |
129 | 129 | { |
130 | 130 | if ($key == 'create') { |
131 | - return new FieldArrangement($this->fieldsWithAssistantFields()->filterBy(function ($field) { |
|
131 | + return new FieldArrangement($this->fieldsWithAssistantFields()->filterBy(function($field) { |
|
132 | 132 | return in_array($field->getKey(), ['title']); |
133 | 133 | })); |
134 | 134 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | public function saveFields(Request $request) |
166 | 166 | { |
167 | 167 | // Store the morph_key upon creation |
168 | - if ($this->model instanceof MorphableContract && ! $this->model->morph_key) { |
|
168 | + if ($this->model instanceof MorphableContract && !$this->model->morph_key) { |
|
169 | 169 | $this->model->morph_key = $this->model->morphKey(); |
170 | 170 | } |
171 | 171 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | if (is_array_empty($translation)) { |
213 | 213 | |
214 | 214 | // Nullify all values |
215 | - $trans[$locale] = array_map(function ($value) { |
|
215 | + $trans[$locale] = array_map(function($value) { |
|
216 | 216 | return null; |
217 | 217 | }, $translation); |
218 | 218 | continue; |
@@ -94,7 +94,7 @@ |
||
94 | 94 | 'baseUrlSegment' => $this->baseUrlSegment, |
95 | 95 | 'hint' => null, // Hint placeholder to show url hint when it already exists |
96 | 96 | 'is_homepage' => ($this->getValue() === '/'), |
97 | - 'show' => !!$this->getValue(),// show input field or not |
|
97 | + 'show' => !!$this->getValue(), // show input field or not |
|
98 | 98 | ]; |
99 | 99 | } |
100 | 100 | } |
@@ -55,14 +55,14 @@ |
||
55 | 55 | { |
56 | 56 | // Complete rule definitions - in the format of [attribute => rules] - will be left as is and are not being manipulated e.g. ['foobar' => 'required'] |
57 | 57 | // Otherwise if the rules are being passed as an array, they will be normalized to a string. |
58 | - if(is_array($values)){ |
|
59 | - if(is_string(key($values))) { |
|
58 | + if (is_array($values)) { |
|
59 | + if (is_string(key($values))) { |
|
60 | 60 | return $values; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $values = reset($values); |
64 | 64 | } |
65 | 65 | |
66 | - return array_fill_keys( $field->getValidationNames($payload) , $values); |
|
66 | + return array_fill_keys($field->getValidationNames($payload), $values); |
|
67 | 67 | } |
68 | 68 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $this->format = $format; |
34 | 34 | $this->placeholders = $this->payload = $this->keysToBeRemoved = []; |
35 | 35 | |
36 | - $this->defaultLocale((string) config('app.fallback_locale', 'nl')); |
|
36 | + $this->defaultLocale((string)config('app.fallback_locale', 'nl')); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public static function fromFormat(string $format) |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | $names = [$this->format]; |
47 | 47 | |
48 | - foreach($this->filters as $filter){ |
|
48 | + foreach ($this->filters as $filter) { |
|
49 | 49 | $names = call_user_func_array([$this, $filter], [$names]); |
50 | 50 | } |
51 | 51 | |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | $newKeySet = []; |
87 | 87 | foreach ($keys as $i => $key) { |
88 | 88 | |
89 | - if(count($replacements) < 1) { |
|
89 | + if (count($replacements) < 1) { |
|
90 | 90 | $newKeySet[] = $key; |
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | |
94 | 94 | foreach ($replacements as $replacement) { |
95 | - $newKeySet[] = str_replace(':' . $placeholder, $replacement, $key); |
|
95 | + $newKeySet[] = str_replace(':'.$placeholder, $replacement, $key); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | $filteredKeys = $keys; |
108 | 108 | |
109 | - foreach($this->keysToBeRemoved as $keyToBeRemoved) { |
|
109 | + foreach ($this->keysToBeRemoved as $keyToBeRemoved) { |
|
110 | 110 | $pattern = preg_quote($keyToBeRemoved, '#'); |
111 | 111 | |
112 | 112 | /* Any asterix which work as an wildcard of characters */ |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $pattern = str_replace('\*', '(.+)', $pattern); |
115 | 115 | } |
116 | 116 | |
117 | - foreach($filteredKeys as $k => $filteredKey) { |
|
117 | + foreach ($filteredKeys as $k => $filteredKey) { |
|
118 | 118 | if (preg_match("#$pattern#", $filteredKey)) { |
119 | 119 | unset($filteredKeys[$k]); |
120 | 120 | } |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | |
135 | 135 | // Remove locales that are considered empty in the request payload |
136 | 136 | foreach ($this->payload['trans'] as $locale => $values) { |
137 | - if ($locale == $this->defaultLocale || ! is_array_empty($values)) { |
|
137 | + if ($locale == $this->defaultLocale || !is_array_empty($values)) { |
|
138 | 138 | continue; |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Remove all 'trans' entries for this locale |
142 | - foreach($filteredKeys as $i => $key){ |
|
143 | - if(Str::startsWith($key, 'trans.'.$locale)) { |
|
142 | + foreach ($filteredKeys as $i => $key) { |
|
143 | + if (Str::startsWith($key, 'trans.'.$locale)) { |
|
144 | 144 | unset($filteredKeys[$i]); |
145 | 145 | } |
146 | 146 | } |
@@ -4,19 +4,19 @@ 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 |
|
15 | - const MEDIA = 'media'; // media file (slim uploader) |
|
16 | - const DOCUMENT = 'document'; // documents |
|
17 | - const RADIO = 'radio'; // radio select |
|
18 | - const CHECKBOX = 'checkbox'; // checkbox select |
|
19 | - const PAGEBUILDER = 'pagebuilder'; // the most special field there is... |
|
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 | + const MEDIA = 'media'; // media file (slim uploader) |
|
16 | + const DOCUMENT = 'document'; // documents |
|
17 | + const RADIO = 'radio'; // radio select |
|
18 | + const CHECKBOX = 'checkbox'; // checkbox select |
|
19 | + const PAGEBUILDER = 'pagebuilder'; // the most special field there is... |
|
20 | 20 | |
21 | 21 | /** @var string */ |
22 | 22 | private $type; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | public function equalsAny(array $types): bool |
47 | 47 | { |
48 | 48 | foreach ($types as $type) { |
49 | - if ($this->equals( FieldType::fromString($type) )) { |
|
49 | + if ($this->equals(FieldType::fromString($type))) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | public function equals($type): bool |
58 | 58 | { |
59 | - return ((string) $type === (string) $this->type && static::class === get_class($type)); |
|
59 | + return ((string)$type === (string)$this->type && static::class === get_class($type)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public function __toString() |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types = 1); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace Thinktomorrow\Chief\Fields\Types; |
4 | 4 |
@@ -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 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $images = []; |
49 | 49 | $locale = $locale ?? app()->getLocale(); |
50 | 50 | |
51 | - $assets = $model->assetRelation->where('pivot.type', $this->getKey())->filter(function ($asset) use ($locale) { |
|
51 | + $assets = $model->assetRelation->where('pivot.type', $this->getKey())->filter(function($asset) use ($locale) { |
|
52 | 52 | return $asset->pivot->locale == $locale; |
53 | 53 | })->sortBy('pivot.order'); |
54 | 54 |
@@ -164,9 +164,9 @@ |
||
164 | 164 | |
165 | 165 | public function prepend($prepend): Field |
166 | 166 | { |
167 | - $this->prepend = $prepend; |
|
167 | + $this->prepend = $prepend; |
|
168 | 168 | |
169 | - return $this; |
|
169 | + return $this; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | public function getPrepend(?string $locale = null): ?string |
@@ -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 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | protected function getValidationNameFormat(): string |
106 | 106 | { |
107 | - if($this->isLocalized()) { |
|
107 | + if ($this->isLocalized()) { |
|
108 | 108 | return $this->getLocalizedNameFormat(); |
109 | 109 | } |
110 | 110 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | protected function getLocalizedNameFormat(): string |
115 | 115 | { |
116 | - if(false !== strpos($this->name, ':locale')){ |
|
116 | + if (false !== strpos($this->name, ':locale')) { |
|
117 | 117 | return $this->name; |
118 | 118 | } |
119 | 119 | |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | */ |
238 | 238 | private function defaultValueResolver(): \Closure |
239 | 239 | { |
240 | - return function (Model $model = null, $locale = null) { |
|
240 | + return function(Model $model = null, $locale = null) { |
|
241 | 241 | |
242 | - if(!$model) return $this->value; |
|
242 | + if (!$model) return $this->value; |
|
243 | 243 | |
244 | 244 | if ($locale && $this->isLocalized()) { |
245 | 245 | return $model->getTranslationFor($this->getColumn(), $locale); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | public function optional(): bool |
290 | 290 | { |
291 | - return ! $this->required(); |
|
291 | + return !$this->required(); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | public function getValidationNames(array $payload = []): array |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | |
395 | 395 | public function getElementView(): string |
396 | 396 | { |
397 | - if($this->elementView) return $this->elementView; |
|
397 | + if ($this->elementView) return $this->elementView; |
|
398 | 398 | |
399 | 399 | return $this->isLocalized() |
400 | 400 | ? 'chief::back._fields.translatable' |
@@ -239,7 +239,9 @@ discard block |
||
239 | 239 | { |
240 | 240 | return function (Model $model = null, $locale = null) { |
241 | 241 | |
242 | - if(!$model) return $this->value; |
|
242 | + if(!$model) { |
|
243 | + return $this->value; |
|
244 | + } |
|
243 | 245 | |
244 | 246 | if ($locale && $this->isLocalized()) { |
245 | 247 | return $model->getTranslationFor($this->getColumn(), $locale); |
@@ -394,7 +396,9 @@ discard block |
||
394 | 396 | |
395 | 397 | public function getElementView(): string |
396 | 398 | { |
397 | - if($this->elementView) return $this->elementView; |
|
399 | + if($this->elementView) { |
|
400 | + return $this->elementView; |
|
401 | + } |
|
398 | 402 | |
399 | 403 | return $this->isLocalized() |
400 | 404 | ? 'chief::back._fields.translatable' |