@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function filtersSortAssistant(): Filters |
30 | 30 | { |
31 | 31 | return new Filters([ |
32 | - HiddenFilter::make('sortIndex', function ($query) { |
|
32 | + HiddenFilter::make('sortIndex', function($query) { |
|
33 | 33 | return $query->orderBy('order', 'ASC'); |
34 | 34 | }), |
35 | 35 | ]); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function sortIndex(Request $request) |
39 | 39 | { |
40 | - if(!$request->indices) { |
|
40 | + if (!$request->indices) { |
|
41 | 41 | throw new \InvalidArgumentException('Missing arguments [indices] for sorting request.'); |
42 | 42 | } |
43 | 43 |
@@ -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 = ModelReferencePresenter::toGroupedSelectValues($availableChildren->onlySets())->toArray(); |
59 | 59 | |
60 | 60 | // Current sections |
61 | - $sections = $model->children()->map(function ($section, $index) use($model) { |
|
61 | + $sections = $model->children()->map(function($section, $index) use($model) { |
|
62 | 62 | if ($section instanceof TranslatableContract) { |
63 | 63 | $section->injectTranslationForForm(); |
64 | 64 | } |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | |
79 | 79 | public function saveCreateFields(Request $request): void |
80 | 80 | { |
81 | - if($this->isManualSortable() && !$request->has('order')) { |
|
82 | - $this->model->order = $this->modelInstance()::orderBy('order', 'desc')->first()->order + 1; |
|
81 | + if ($this->isManualSortable() && !$request->has('order')) { |
|
82 | + $this->model->order = $this->modelInstance()::orderBy('order', 'desc')->first()->order+1; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | $this->saveFields($request, $this->createFields()); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | return $this->indexPagination($builder); |
107 | 107 | } |
108 | 108 | |
109 | - return $builder->get()->map(function ($model) { |
|
109 | + return $builder->get()->map(function($model) { |
|
110 | 110 | return (new static($this->registration))->manage($model); |
111 | 111 | }); |
112 | 112 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | protected function indexSorting(Builder $builder): Builder |
127 | 127 | { |
128 | - if($this->isManualSortable()) { |
|
128 | + if ($this->isManualSortable()) { |
|
129 | 129 | $builder->sortedManually(); |
130 | 130 | } |
131 | 131 | |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | { |
146 | 146 | $paginator = $builder->paginate($this->pageCount); |
147 | 147 | |
148 | - $modifiedCollection = $builder->paginate($this->pageCount)->getCollection()->transform(function ($model) { |
|
148 | + $modifiedCollection = $builder->paginate($this->pageCount)->getCollection()->transform(function($model) { |
|
149 | 149 | return (new static($this->registration))->manage($model); |
150 | 150 | }); |
151 | 151 | |
152 | - foreach(request()->query() as $key => $value) { |
|
153 | - if($key == 'page') continue; |
|
152 | + foreach (request()->query() as $key => $value) { |
|
153 | + if ($key == 'page') continue; |
|
154 | 154 | $paginator->appends($key, $value); |
155 | 155 | } |
156 | 156 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | { |
275 | 275 | $fields = $this->fieldsWithAssistantFields(); |
276 | 276 | |
277 | - if($this->isManualSortable() && !$fields->offsetExists('order')) { |
|
277 | + if ($this->isManualSortable() && !$fields->offsetExists('order')) { |
|
278 | 278 | $fields = $fields->add(NumberField::make('order')); |
279 | 279 | } |
280 | 280 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | public function editFields(): Fields |
285 | 285 | { |
286 | - return $this->fieldsWithAssistantFields()->map(function (Field $field) { |
|
286 | + return $this->fieldsWithAssistantFields()->map(function(Field $field) { |
|
287 | 287 | return $field->model($this->model); |
288 | 288 | }); |
289 | 289 | } |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | static::$bootedTraitMethods[$baseMethod] = []; |
377 | 377 | |
378 | 378 | foreach (class_uses_recursive($class) as $trait) { |
379 | - $method = class_basename($trait) . ucfirst($baseMethod); |
|
379 | + $method = class_basename($trait).ucfirst($baseMethod); |
|
380 | 380 | |
381 | 381 | if (method_exists($class, $method) && !in_array($method, static::$bootedTraitMethods[$baseMethod])) { |
382 | 382 | static::$bootedTraitMethods[$baseMethod][] = lcfirst($method); |
@@ -150,7 +150,9 @@ |
||
150 | 150 | }); |
151 | 151 | |
152 | 152 | foreach(request()->query() as $key => $value) { |
153 | - if($key == 'page') continue; |
|
153 | + if($key == 'page') { |
|
154 | + continue; |
|
155 | + } |
|
154 | 156 | $paginator->appends($key, $value); |
155 | 157 | } |
156 | 158 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | // If no view has been created for this page collection, we try once again to fetch the content value if any. This will silently fail |
53 | 53 | // if no content value is present. We don't consider the 'content' attribute to be a default as we do for module. |
54 | - return $this->map(function ($item) { |
|
54 | + return $this->map(function($item) { |
|
55 | 55 | return ($this->viewParent && $item instanceof ViewableContract) |
56 | 56 | ? $item->setViewParent($this->viewParent)->renderView() |
57 | 57 | : ($item->content ?? ''); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $path = request()->path(); |
87 | 87 | |
88 | 88 | // When we have an entire collection as result we will cut down the items here, else if already paginated, we'll keep it as is. |
89 | - $items = $this->comingFromPaginatedCollection() ? $this->all() :array_slice($this->all(), ($currentPage - 1) * $perPage); |
|
89 | + $items = $this->comingFromPaginatedCollection() ? $this->all() : array_slice($this->all(), ($currentPage-1) * $perPage); |
|
90 | 90 | |
91 | 91 | return (new \Illuminate\Pagination\Paginator($items, $perPage ?? $this->paginateSetting('perPage', '12'), $currentPage))->setPath($path); |
92 | 92 | } |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | public function paginate($perPage = null, $currentPage = null): Paginator |
103 | 103 | { |
104 | 104 | $currentPage = $currentPage ?? request()->get('page', 1); |
105 | - $path = '/' . request()->path(); |
|
105 | + $path = '/'.request()->path(); |
|
106 | 106 | |
107 | 107 | // When we have an entire collection as result we will cut down the items here, else if already paginated, we'll keep it as is. |
108 | - $items = $this->comingFromPaginatedCollection() ? $this->all() : array_slice($this->all(), ($currentPage - 1) * $perPage, $perPage); |
|
108 | + $items = $this->comingFromPaginatedCollection() ? $this->all() : array_slice($this->all(), ($currentPage-1) * $perPage, $perPage); |
|
109 | 109 | |
110 | 110 | return (new \Illuminate\Pagination\LengthAwarePaginator($items, $this->paginateSetting('total', $this->count()), $perPage ?? $this->paginateSetting('perPage', '12'), $currentPage))->setPath($path); |
111 | 111 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $this->pageBuilderField(), |
85 | 85 | InputField::make('title')->translatable($this->model->availableLocales()) |
86 | 86 | ->validation('required-fallback-locale|max:200', [], [ |
87 | - 'trans.' . config('app.fallback_locale', 'nl') . '.title' => 'title', |
|
87 | + 'trans.'.config('app.fallback_locale', 'nl').'.title' => 'title', |
|
88 | 88 | ]) |
89 | 89 | ->label('Intern label') |
90 | 90 | ->description('Dit is de benaming die zal worden getoond in de admin selectie velden.') |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | $this->model->morph_key = $this->model->morphKey(); |
154 | 154 | } |
155 | 155 | |
156 | - if($this->isManualSortable() && !$request->has('order')) { |
|
157 | - $this->model->order = $this->modelInstance()::orderBy('order', 'desc')->first()->order + 1; |
|
156 | + if ($this->isManualSortable() && !$request->has('order')) { |
|
157 | + $this->model->order = $this->modelInstance()::orderBy('order', 'desc')->first()->order+1; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | parent::saveFields($request, $this->createFields()->merge($this->fieldsWithAssistantFields()->keyed('url-slugs'))); |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | if (!isset($urls[$locale]) && isset($translation['title'])) { |
204 | 204 | $append = ''; $i = 1; |
205 | 205 | |
206 | - do{ |
|
207 | - $urls[$locale] = Str::slug($translation['title']) . $append; |
|
206 | + do { |
|
207 | + $urls[$locale] = Str::slug($translation['title']).$append; |
|
208 | 208 | $append = "$i"; |
209 | 209 | $i++; |
210 | 210 | } |
211 | - while(!$urlValidator->passes(null, [$locale => $urls[$locale]])); |
|
211 | + while (!$urlValidator->passes(null, [$locale => $urls[$locale]])); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | if (is_array_empty($translation)) { |
224 | 224 | |
225 | 225 | // Nullify all values |
226 | - $trans[$locale] = array_map(function ($value) { |
|
226 | + $trans[$locale] = array_map(function($value) { |
|
227 | 227 | return null; |
228 | 228 | }, $translation); |
229 | 229 | continue; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | foreach ($this->children as $i => $child) { |
67 | 67 | |
68 | 68 | // Do not render offline relations |
69 | - if($child->relation->isOffline()) continue; |
|
69 | + if ($child->relation->isOffline()) continue; |
|
70 | 70 | |
71 | 71 | if ($child instanceof StoredSetReference) { |
72 | 72 | $this->addSetToCollection($i, $child->toSet($this->parent)); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $this->addModelToCollection($i, $child); |
92 | 92 | } |
93 | 93 | |
94 | - return $this->sets->values()->map(function (ViewableContract $child) { |
|
94 | + return $this->sets->values()->map(function(ViewableContract $child) { |
|
95 | 95 | return $child->setViewParent($this->parent)->renderView(); |
96 | 96 | }); |
97 | 97 | } |
@@ -70,7 +70,9 @@ |
||
70 | 70 | foreach ($this->children as $i => $child) { |
71 | 71 | |
72 | 72 | // Do not render offline relations |
73 | - if($child->relation->isOffline()) continue; |
|
73 | + if($child->relation->isOffline()) { |
|
74 | + continue; |
|
75 | + } |
|
74 | 76 | |
75 | 77 | if ($child instanceof StoredSetReference) { |
76 | 78 | $this->addSetToCollection($i, $child->toSet($this->parent)); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $this->removeModules($referred_instances); |
55 | 55 | |
56 | 56 | foreach ($referred_instances as $i => $instance) { |
57 | - if(!$relation = Relation::find($this->model->getMorphClass(), $this->model->id, $instance->getMorphClass(), $instance->id)) { |
|
57 | + if (!$relation = Relation::find($this->model->getMorphClass(), $this->model->id, $instance->getMorphClass(), $instance->id)) { |
|
58 | 58 | $this->model->adoptChild($instance, ['sort' => $i]); |
59 | 59 | } |
60 | 60 | } |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | |
65 | 65 | public function updateSets() |
66 | 66 | { |
67 | - $stored_set_refs = collect($this->set_refs)->reject(function($ref){ |
|
67 | + $stored_set_refs = collect($this->set_refs)->reject(function($ref) { |
|
68 | 68 | return !$ref; |
69 | - })->map(function($flat_set_ref){ |
|
69 | + })->map(function($flat_set_ref) { |
|
70 | 70 | return $this->findOrCreateStoredSetReference($flat_set_ref); |
71 | 71 | }); |
72 | 72 | |
73 | 73 | $this->removeSets($stored_set_refs); |
74 | 74 | |
75 | 75 | foreach ($stored_set_refs as $i => $stored_set_ref) { |
76 | - if(!$relation = Relation::find($this->model->getMorphClass(), $this->model->id, $stored_set_ref->getMorphClass(), $stored_set_ref->id)) { |
|
76 | + if (!$relation = Relation::find($this->model->getMorphClass(), $this->model->id, $stored_set_ref->getMorphClass(), $stored_set_ref->id)) { |
|
77 | 77 | $this->model->adoptChild($stored_set_ref, ['sort' => $i]); |
78 | 78 | } |
79 | 79 | } |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | */ |
88 | 88 | private function removeModules(Collection $referred_instances): void |
89 | 89 | { |
90 | - $this->model->children()->filter(function ($instance) { |
|
90 | + $this->model->children()->filter(function($instance) { |
|
91 | 91 | return (!$instance instanceof StoredSetReference && !$instance instanceof TextModule && !$instance instanceof PagetitleModule); |
92 | - })->reject(function ($instance) use ($referred_instances) { |
|
92 | + })->reject(function($instance) use ($referred_instances) { |
|
93 | 93 | // If this model still exists in the update request, we'll reject it from the removed list. |
94 | - return $referred_instances->filter(function ($referred_instance) use ($instance) { |
|
94 | + return $referred_instances->filter(function($referred_instance) use ($instance) { |
|
95 | 95 | return (get_class($referred_instance) == get_class($instance) && $referred_instance->id == $instance->id); |
96 | 96 | })->isNotEmpty(); |
97 | - })->each(function ($instance) { |
|
97 | + })->each(function($instance) { |
|
98 | 98 | $this->model->rejectChild($instance); |
99 | 99 | }); |
100 | 100 | } |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | */ |
106 | 106 | private function removeSets(Collection $referred_instances): void |
107 | 107 | { |
108 | - $this->model->children()->filter(function ($instance) { |
|
108 | + $this->model->children()->filter(function($instance) { |
|
109 | 109 | return ($instance instanceof StoredSetReference); |
110 | - })->reject(function ($instance) use ($referred_instances) { |
|
110 | + })->reject(function($instance) use ($referred_instances) { |
|
111 | 111 | // If this model still exists in the update request, we'll reject it from the removed list. |
112 | - return $referred_instances->filter(function ($referred_instance) use ($instance) { |
|
112 | + return $referred_instances->filter(function($referred_instance) use ($instance) { |
|
113 | 113 | return (get_class($referred_instance) == get_class($instance) && $referred_instance->id == $instance->id); |
114 | 114 | })->isNotEmpty(); |
115 | - })->each(function ($instance) { |
|
115 | + })->each(function($instance) { |
|
116 | 116 | $this->model->rejectChild($instance); |
117 | 117 | }); |
118 | 118 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | continue; |
230 | 230 | } |
231 | 231 | |
232 | - $child = $children->first(function ($c) use ($reference) { |
|
232 | + $child = $children->first(function($c) use ($reference) { |
|
233 | 233 | return $c->flatReference()->get() == $reference; |
234 | 234 | }); |
235 | 235 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | private function stripTagsBlacklist($value, $blacklist = []) |
281 | 281 | { |
282 | 282 | foreach ($blacklist as $tag) { |
283 | - $value = preg_replace('/<\/?' . $tag . '(.|\s)*?>/', '', $value); |
|
283 | + $value = preg_replace('/<\/?'.$tag.'(.|\s)*?>/', '', $value); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | return $value; |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | public static function find(string $parent_type, $parent_id, string $child_type, $child_id): ?Relation |
22 | 22 | { |
23 | 23 | return static::query() |
24 | - ->where('parent_type', $parent_type ) |
|
25 | - ->where('parent_id', $parent_id ) |
|
26 | - ->where('child_type', $child_type ) |
|
27 | - ->where('child_id', $child_id ) |
|
24 | + ->where('parent_type', $parent_type) |
|
25 | + ->where('parent_id', $parent_id) |
|
26 | + ->where('child_type', $child_type) |
|
27 | + ->where('child_id', $child_id) |
|
28 | 28 | ->first(); |
29 | 29 | } |
30 | 30 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ->orderBy('sort', 'ASC') |
76 | 76 | ->get(); |
77 | 77 | |
78 | - return $relations->map(function (Relation $relation) { |
|
78 | + return $relations->map(function(Relation $relation) { |
|
79 | 79 | $parent = $relation->parent; |
80 | 80 | $parent->relation = $relation; |
81 | 81 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | ->orderBy('sort', 'ASC') |
92 | 92 | ->get(); |
93 | 93 | |
94 | - return $relations->map(function (Relation $relation) use ($parent_type, $parent_id) { |
|
94 | + return $relations->map(function(Relation $relation) use ($parent_type, $parent_id) { |
|
95 | 95 | |
96 | 96 | // It could be that the child itself is archived, soft-deleted or removed. If this is the case, we will ignore it and move on. |
97 | 97 | if (!$child = $relation->child) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | }) |
105 | 105 | |
106 | 106 | // 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 |
107 | - ->reject(function ($child) { |
|
107 | + ->reject(function($child) { |
|
108 | 108 | return is_null($child); |
109 | 109 | }) |
110 | 110 | ->values(); |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | |
122 | 122 | public static function deleteRelationsOf($type, $id) |
123 | 123 | { |
124 | - $relations = static::where(function ($query) use ($type, $id) { |
|
124 | + $relations = static::where(function($query) use ($type, $id) { |
|
125 | 125 | return $query->where('parent_type', $type) |
126 | 126 | ->where('parent_id', $id); |
127 | - })->orWhere(function ($query) use ($type, $id) { |
|
127 | + })->orWhere(function($query) use ($type, $id) { |
|
128 | 128 | return $query->where('child_type', $type) |
129 | 129 | ->where('child_id', $id); |
130 | 130 | })->get(); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | public static function deleteAllChildRelationsOf($type, $id) |
138 | 138 | { |
139 | - $relations = static::where(function ($query) use ($type, $id) { |
|
139 | + $relations = static::where(function($query) use ($type, $id) { |
|
140 | 140 | return $query->where('parent_type', $type) |
141 | 141 | ->where('parent_id', $id); |
142 | 142 | })->get(); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | public static function deleteAllParentRelationsOf($type, $id) |
150 | 150 | { |
151 | - $relations = static::where(function ($query) use ($type, $id) { |
|
151 | + $relations = static::where(function($query) use ($type, $id) { |
|
152 | 152 | return $query->where('child_type', $type) |
153 | 153 | ->where('child_id', $id); |
154 | 154 | })->get(); |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | return $filename; |
141 | 141 | } |
142 | 142 | |
143 | - $extension = substr($filename, strrpos($filename, '.') + 1); |
|
143 | + $extension = substr($filename, strrpos($filename, '.')+1); |
|
144 | 144 | $filename = substr($filename, 0, strrpos($filename, '.')); |
145 | 145 | |
146 | - return Str::slug($filename) . '.' . $extension; |
|
146 | + return Str::slug($filename).'.'.$extension; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | protected function sort(HasAsset $model, MediaField $field, array $input) |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | $values = isset($fileIdInput[$key]) |
170 | 170 | ? $fileIdInput[$key] |
171 | 171 | : ( |
172 | - isset($fileIdInput['files-' . $key]) |
|
173 | - ? $fileIdInput['files-' . $key] |
|
172 | + isset($fileIdInput['files-'.$key]) |
|
173 | + ? $fileIdInput['files-'.$key] |
|
174 | 174 | : '' |
175 | 175 | ); |
176 | 176 |