@@ -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(); |
@@ -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 |