Skip to content

Commit

Permalink
fix(filters): fix number filter (#1153)
Browse files Browse the repository at this point in the history
* fix(filters): fix number filter

unable to execute sql with incorrect cast text user input to number field

* fix phpstan

---------

Co-authored-by: luanfreitasdev <[email protected]>
  • Loading branch information
jamesRUS52 and luanfreitasdev authored Sep 15, 2023
1 parent 79da200 commit 30c38f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Traits/HasFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ public function filterNumberStart(array $params, string $value): void

$this->resetPage();

$value = filter_var($value, FILTER_SANITIZE_NUMBER_INT);

$this->filters['number'][$field]['start'] = $value;
$this->filters['number'][$field]['thousands'] = $thousands;
$this->filters['number'][$field]['decimal'] = $decimal;
Expand All @@ -318,6 +320,8 @@ public function filterNumberEnd(array $params, string $value): void

$this->resetPage();

$value = filter_var($value, FILTER_SANITIZE_NUMBER_INT);

$this->filters['number'][$field]['end'] = $value;
$this->filters['number'][$field]['thousands'] = $thousands;
$this->filters['number'][$field]['decimal'] = $decimal;
Expand All @@ -329,7 +333,7 @@ public function filterNumberEnd(array $params, string $value): void
$this->clearFilter($field, emit: false);
}

$this->afterChangedNumberEndFilter($field, $value, $title);
$this->afterChangedNumberEndFilter($field, $title, $value);

$this->persistState('filters');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/Listeners.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public function afterChangedBooleanFilter(string $field, string $label, string $
{
}

public function afterChangedNumberStartFilter(string $field, string $label, string $value): void
public function afterChangedNumberStartFilter(string $field, string $label, string|false $value): void
{
}

public function afterChangedNumberEndFilter(string $field, string $label, string $value): void
public function afterChangedNumberEndFilter(string $field, string $label, string|false $value): void
{
}
}

0 comments on commit 30c38f3

Please sign in to comment.