Skip to content

Commit

Permalink
Handle multiple preset query strings (URL & tag conditions)
Browse files Browse the repository at this point in the history
  • Loading branch information
afonic committed Nov 10, 2024
1 parent 15c5f62 commit 9b1264a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Http/Livewire/Traits/HandleParams.php
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 9b1264a

Please sign in to comment.