@@ -21,7 +21,7 @@ discard block |
||
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 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $files = []; |
36 | 36 | $locale = $locale ?? app()->getLocale(); |
37 | 37 | |
38 | - $assets = $model->assetRelation->where('pivot.type', $this->getKey())->filter(function ($asset) use ($locale) { |
|
38 | + $assets = $model->assetRelation->where('pivot.type', $this->getKey())->filter(function($asset) use ($locale) { |
|
39 | 39 | return $asset->pivot->locale == $locale; |
40 | 40 | })->sortBy('pivot.order'); |
41 | 41 |
@@ -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,30 +108,30 @@ 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 | - return new static(array_filter($this->fields, function (Field $field) use ($keys) { |
|
120 | + return new static(array_filter($this->fields, function(Field $field) use ($keys) { |
|
121 | 121 | return in_array($field->getKey(), $keys); |
122 | 122 | })); |
123 | 123 | } |
124 | 124 | |
125 | 125 | public function tagged($tag): Fields |
126 | 126 | { |
127 | - return new static(array_filter($this->fields, function (Field $field) use ($tag) { |
|
127 | + return new static(array_filter($this->fields, function(Field $field) use ($tag) { |
|
128 | 128 | return $field->tagged($tag); |
129 | 129 | })); |
130 | 130 | } |
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 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function offsetGet($offset) |
174 | 174 | { |
175 | 175 | if (!isset($this->fields[$offset])) { |
176 | - throw new \RuntimeException('No field found by key [' . $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 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | |
27 | 27 | if ($reference->hasFragmentKey()) { |
28 | 28 | if (!$field instanceof FragmentField) { |
29 | - throw new \RuntimeException('Field ' . $field->getKey() . ' was expected to be a fragmentfield but its not.'); |
|
29 | + throw new \RuntimeException('Field '.$field->getKey().' was expected to be a fragmentfield but its not.'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $firstFragment = $field->getFragments()[0]; |
@@ -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 | const PAGE = 'page'; // select a page (also a special field) |
24 | 24 |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | public static function modelsByType(array $types, Model $ignoredModel = null, bool $online = true) |
91 | 91 | { |
92 | - $models = chiefMemoize('all-online-models', function () use ($types, $online) { |
|
92 | + $models = chiefMemoize('all-online-models', function() use ($types, $online) { |
|
93 | 93 | $builder = UrlRecord::whereNull('redirect_id') |
94 | 94 | ->select('model_type', 'model_id') |
95 | 95 | ->groupBy('model_type', 'model_id'); |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | $builder->whereIn('model_type', $types); |
99 | 99 | } |
100 | 100 | |
101 | - return $builder->get()->mapToGroups(function ($record) { |
|
101 | + return $builder->get()->mapToGroups(function($record) { |
|
102 | 102 | return [$record->model_type => $record->model_id]; |
103 | - })->map(function ($record, $key) { |
|
103 | + })->map(function($record, $key) { |
|
104 | 104 | return Morphables::instance($key)->find($record->toArray()); |
105 | - })->map->reject(function ($model) use ($online) { |
|
105 | + })->map->reject(function($model) use ($online) { |
|
106 | 106 | if ($online) { |
107 | 107 | return is_null($model) || !$model->isPublished(); |
108 | 108 | } // Invalid references to archived or removed models where url record still exists. |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | }); |
113 | 113 | |
114 | 114 | if ($ignoredModel) { |
115 | - $models = $models->reject(function ($model) use ($ignoredModel) { |
|
115 | + $models = $models->reject(function($model) use ($ignoredModel) { |
|
116 | 116 | return (get_class($model) === get_class($ignoredModel) && $model->id === $ignoredModel->id); |
117 | 117 | }); |
118 | 118 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | ->orderBy('sort', 'ASC') |
55 | 55 | ->get(); |
56 | 56 | |
57 | - return $relations->map(function (Relation $relation) { |
|
57 | + return $relations->map(function(Relation $relation) { |
|
58 | 58 | $parent = $relation->parent; |
59 | 59 | $parent->relation = $relation; |
60 | 60 | |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | ->orderBy('sort', 'ASC') |
71 | 71 | ->get(); |
72 | 72 | |
73 | - return $relations->map(function (Relation $relation) use ($parent_type, $parent_id) { |
|
73 | + return $relations->map(function(Relation $relation) use ($parent_type, $parent_id) { |
|
74 | 74 | |
75 | 75 | // It could be that the child itself is soft-deleted, if this is the case, we will ignore it and move on. |
76 | 76 | if (!$child = $relation->child) { |
77 | 77 | if (!$relation->child()->withTrashed()->first()) { |
78 | 78 | // If we cannot retrieve it then the relation type is possibly wrong, this is a database inconsistency and should be addressed |
79 | - throw new \DomainException('Corrupt relation reference. Related child [' . $relation->child_type . '@' . $relation->child_id . '] could not be retrieved for parent [' . $parent_type . '@' . $parent_id . ']. Make sure the morph key can resolve to a valid class.'); |
|
79 | + throw new \DomainException('Corrupt relation reference. Related child ['.$relation->child_type.'@'.$relation->child_id.'] could not be retrieved for parent ['.$parent_type.'@'.$parent_id.']. Make sure the morph key can resolve to a valid class.'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return null; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | }) |
89 | 89 | |
90 | 90 | // In case of soft-deleted entries, this will be null and should be ignored. We make sure that keys are reset in case of removed child |
91 | - ->reject(function ($child) { |
|
91 | + ->reject(function($child) { |
|
92 | 92 | return is_null($child); |
93 | 93 | }) |
94 | 94 | ->values(); |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | |
106 | 106 | public static function deleteRelationsOf($type, $id) |
107 | 107 | { |
108 | - $relations = static::where(function ($query) use ($type, $id) { |
|
108 | + $relations = static::where(function($query) use ($type, $id) { |
|
109 | 109 | return $query->where('parent_type', $type) |
110 | 110 | ->where('parent_id', $id); |
111 | - })->orWhere(function ($query) use ($type, $id) { |
|
111 | + })->orWhere(function($query) use ($type, $id) { |
|
112 | 112 | return $query->where('child_type', $type) |
113 | 113 | ->where('child_id', $id); |
114 | 114 | })->get(); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | public static function deleteAllChildRelationsOf($type, $id) |
122 | 122 | { |
123 | - $relations = static::where(function ($query) use ($type, $id) { |
|
123 | + $relations = static::where(function($query) use ($type, $id) { |
|
124 | 124 | return $query->where('parent_type', $type) |
125 | 125 | ->where('parent_id', $id); |
126 | 126 | })->get(); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | public static function deleteAllParentRelationsOf($type, $id) |
134 | 134 | { |
135 | - $relations = static::where(function ($query) use ($type, $id) { |
|
135 | + $relations = static::where(function($query) use ($type, $id) { |
|
136 | 136 | return $query->where('child_type', $type) |
137 | 137 | ->where('child_id', $id); |
138 | 138 | })->get(); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | ->performedOn($this->manager->existingModel()) |
62 | 62 | ->log('published'); |
63 | 63 | |
64 | - return redirect()->back()->with('messages.success', $this->manager->details()->title . ' is online gezet.'); |
|
64 | + return redirect()->back()->with('messages.success', $this->manager->details()->title.' is online gezet.'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public function unpublish() |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | ->performedOn($this->manager->existingModel()) |
76 | 76 | ->log('unpublished'); |
77 | 77 | |
78 | - return redirect()->back()->with('messages.success', $this->manager->details()->title . ' is offline gehaald.'); |
|
78 | + return redirect()->back()->with('messages.success', $this->manager->details()->title.' is offline gehaald.'); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function findAll(): Collection |
82 | 82 | { |
83 | - return $this->manager->existingModel()->published()->get()->map(function ($model) { |
|
83 | + return $this->manager->existingModel()->published()->get()->map(function($model) { |
|
84 | 84 | return $this->managers->findByModel($model); |
85 | 85 | }); |
86 | 86 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | $class = 'text-warning'; |
138 | 138 | } |
139 | 139 | |
140 | - $statusAsLabel = '<span class="' . $class . '">' . $label . '</span>'; |
|
140 | + $statusAsLabel = '<span class="'.$class.'">'.$label.'</span>'; |
|
141 | 141 | |
142 | 142 | if (!$plain && $this->hasUrl()) { |
143 | - $statusAsLabel = '<a href="' . $this->url() . '" target="_blank">' . $statusAsLabel . '</a>'; |
|
143 | + $statusAsLabel = '<a href="'.$this->url().'" target="_blank">'.$statusAsLabel.'</a>'; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return $statusAsLabel; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | return static::$managedModelKey; |
102 | 102 | } |
103 | 103 | |
104 | - throw new \Exception('Missing required static property \'managedModelKey\' on ' . static::class . '.'); |
|
104 | + throw new \Exception('Missing required static property \'managedModelKey\' on '.static::class.'.'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | public function flatReferenceLabel(): string |
142 | 142 | { |
143 | 143 | if ($this->exists) { |
144 | - $status = !$this->isPublished() ? ' [' . $this->statusAsPlainLabel() . ']' : null; |
|
144 | + $status = !$this->isPublished() ? ' ['.$this->statusAsPlainLabel().']' : null; |
|
145 | 145 | |
146 | - return $this->title ? $this->title . $status : ''; |
|
146 | + return $this->title ? $this->title.$status : ''; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return ''; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $classKey = get_class($this); |
155 | 155 | if (property_exists($this, 'labelSingular')) { |
156 | 156 | $labelSingular = $this->labelSingular; |
157 | - } else { |
|
157 | + }else { |
|
158 | 158 | $labelSingular = Str::singular($classKey); |
159 | 159 | } |
160 | 160 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $locale = app()->getLocale(); |
195 | 195 | } |
196 | 196 | try { |
197 | - $memoizedKey = $this->getMorphClass() . '-' . $this->id . '-' . $locale; |
|
197 | + $memoizedKey = $this->getMorphClass().'-'.$this->id.'-'.$locale; |
|
198 | 198 | |
199 | 199 | if (isset(static::$cachedUrls[$memoizedKey])) { |
200 | 200 | return static::$cachedUrls[$memoizedKey]; |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | public function statusAsLabel() |
251 | 251 | { |
252 | 252 | if ($this->isPublished()) { |
253 | - return '<a href="' . $this->url() . '" target="_blank"><em>online</em></a>'; |
|
253 | + return '<a href="'.$this->url().'" target="_blank"><em>online</em></a>'; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | if ($this->isDraft()) { |
257 | - return '<a href="' . $this->url() . '" target="_blank" class="text-error"><em>offline</em></a>'; |
|
257 | + return '<a href="'.$this->url().'" target="_blank" class="text-error"><em>offline</em></a>'; |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | if ($this->isArchived()) { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | $availableChildren = AvailableChildren::forParent($model); |
51 | 51 | |
52 | - $modules = $availableChildren->onlyModules()->reject(function ($module) use ($model) { |
|
52 | + $modules = $availableChildren->onlyModules()->reject(function($module) use ($model) { |
|
53 | 53 | return $module->owner_id != null && $module->owner_id != $model->id; |
54 | 54 | }); |
55 | 55 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $available_sets = FlatReferencePresenter::toGroupedSelectValues($availableChildren->onlySets())->toArray(); |
59 | 59 | |
60 | 60 | // Current sections |
61 | - $sections = $model->children()->map(function ($section, $index) { |
|
61 | + $sections = $model->children()->map(function($section, $index) { |
|
62 | 62 | if ($section instanceof TranslatableContract) { |
63 | 63 | $section->injectTranslationForForm(); |
64 | 64 | } |