Skip to content

Commit

Permalink
Add Query String prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
dansysanalyst committed May 24, 2024
1 parent 44ca97b commit 0d83ca7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Concerns/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public function addEnabledFilters(string $field, ?string $label): void
}
}

public function listColumnForFilters(): Collection
public function listColumnForQueryString(): Collection
{
$columns = collect();

Expand All @@ -348,17 +348,21 @@ public function listColumnForFilters(): Collection
return $columns;
}

/*
@TODO Figure out
*/
protected function powerGridQueryString(): array
/**
*
* @param string $prefix Prefix each field in URL
*/
protected function powerGridQueryString(string $prefix = ''): array
{
$queryString = [];

$columns = $this->listColumnForFilters();
$columns = $this->listColumnForQueryString();

foreach (Arr::dot($this->filters()) as $filter) {
$as = str($filter->field)->replace('.', '_');
$as = str($filter->field)
->when(!empty($prefix), fn ($c) => $c->prepend($prefix . '_'))
->replace('.', '_')
->replaceMatches('/\_+/', '_');

if (!empty(request()->get($as))) {
$this->addEnabledFilters($filter->field, strval($columns->get($filter->field, $filter->field)));
Expand Down

0 comments on commit 0d83ca7

Please sign in to comment.