Skip to content

Commit

Permalink
Move exception check
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVanderbist committed Oct 5, 2020
1 parent db3b34c commit a0e8140
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Concerns/FiltersQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ protected function isFilterRequested(AllowedFilter $allowedFilter): bool

protected function ensureAllFiltersExist()
{
if (config('query_builder.disable_invalid_filter_query_exception')) {
return;
}

$filterNames = $this->request->filters()->keys();

$allowedFilterNames = $this->allowedFilters->map(function (AllowedFilter $allowedFilter) {
Expand All @@ -70,7 +74,7 @@ protected function ensureAllFiltersExist()

$diff = $filterNames->diff($allowedFilterNames);

if ($diff->count() && ! config('query_builder.disable_invalid_filter_query_exception')) {
if ($diff->count()) {
throw InvalidFilterQuery::filtersNotAllowed($diff, $allowedFilterNames);
}
}
Expand Down

0 comments on commit a0e8140

Please sign in to comment.