diff --git a/src/Http/Livewire/Traits/HandleParams.php b/src/Http/Livewire/Traits/HandleParams.php index 9e7ed5a..1ee683f 100644 --- a/src/Http/Livewire/Traits/HandleParams.php +++ b/src/Http/Livewire/Traits/HandleParams.php @@ -11,7 +11,7 @@ trait HandleParams public function setParameters($params) { if ($customUrlParams = $this->handleCustomQueryStringParams()) { - $params = array_merge($params, $customUrlParams); + $params = $this->mergeParameters($params, $customUrlParams); } $paramsCollection = collect($params); @@ -175,6 +175,18 @@ public function clearFilter($field, $condition, $modifier): void $this->dispatchParamsUpdated(); } + protected function mergeParameters($params, $urlParams): array + { + if (isset($params['query_scope']) && isset($urlParams['query_scope'])) { + $urlParams['query_scope'] = collect(explode('|', $params['query_scope'])) + ->merge(explode('|', $urlParams['query_scope'])) + ->unique() + ->implode('|'); + } + + return array_merge($params, $urlParams); + } + protected function toPipeSeparatedString($payload): string { return is_array($payload) ? implode('|', $payload) : $payload;