From 2a72cd3e440575719859b653a098787dba69e8df Mon Sep 17 00:00:00 2001 From: Wouter Henderickx Date: Wed, 6 Aug 2025 13:23:21 +0200 Subject: [PATCH] make throwing exceptions on unknown filters optional --- src/Concerns/FiltersQuery.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Concerns/FiltersQuery.php b/src/Concerns/FiltersQuery.php index 8407cb29..50b85a4e 100644 --- a/src/Concerns/FiltersQuery.php +++ b/src/Concerns/FiltersQuery.php @@ -10,6 +10,15 @@ trait FiltersQuery { protected Collection $allowedFilters; + protected bool $throwFilterExceptions = true; + + public function throwFilterExceptions(bool $throw = true): static + { + $this->throwFilterExceptions = $throw; + + return $this; + } + public function allowedFilters($filters): static { $filters = is_array($filters) ? $filters : func_get_args(); @@ -60,7 +69,7 @@ protected function isFilterRequested(AllowedFilter $allowedFilter): bool protected function ensureAllFiltersExist(): void { - if (config('query-builder.disable_invalid_filter_query_exception', false)) { + if (config('query-builder.disable_invalid_filter_query_exception', false) || ! $this->throwFilterExceptions) { return; }