| @@ 8-32 (lines=25) @@ | ||
| 5 | use Illuminate\Http\Response; |
|
| 6 | use Illuminate\Support\Collection; |
|
| 7 | ||
| 8 | class InvalidFilterQuery extends InvalidQuery |
|
| 9 | { |
|
| 10 | /** @var \Illuminate\Support\Collection */ |
|
| 11 | public $unknownFilters; |
|
| 12 | ||
| 13 | /** @var \Illuminate\Support\Collection */ |
|
| 14 | public $allowedFilters; |
|
| 15 | ||
| 16 | public function __construct(Collection $unknownFilters, Collection $allowedFilters) |
|
| 17 | { |
|
| 18 | $this->unknownFilters = $unknownFilters; |
|
| 19 | $this->allowedFilters = $allowedFilters; |
|
| 20 | ||
| 21 | $unknownFilters = $this->unknownFilters->implode(', '); |
|
| 22 | $allowedFilters = $this->allowedFilters->implode(', '); |
|
| 23 | $message = "Given filter(s) `{$unknownFilters}` are not allowed. Allowed filter(s) are `{$allowedFilters}`."; |
|
| 24 | ||
| 25 | parent::__construct(Response::HTTP_BAD_REQUEST, $message); |
|
| 26 | } |
|
| 27 | ||
| 28 | public static function filtersNotAllowed(Collection $unknownFilters, Collection $allowedFilters) |
|
| 29 | { |
|
| 30 | return new static(...func_get_args()); |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||
| @@ 8-32 (lines=25) @@ | ||
| 5 | use Illuminate\Http\Response; |
|
| 6 | use Illuminate\Support\Collection; |
|
| 7 | ||
| 8 | class InvalidSearchQuery extends InvalidQuery |
|
| 9 | { |
|
| 10 | /** @var \Illuminate\Support\Collection */ |
|
| 11 | public $unknownSearches; |
|
| 12 | ||
| 13 | /** @var \Illuminate\Support\Collection */ |
|
| 14 | public $allowedSearches; |
|
| 15 | ||
| 16 | public function __construct(Collection $unknownSearches, Collection $allowedSearches) |
|
| 17 | { |
|
| 18 | $this->unknownSearches = $unknownSearches; |
|
| 19 | $this->allowedSearches = $allowedSearches; |
|
| 20 | ||
| 21 | $unknownSearches = $this->unknownSearches->implode(', '); |
|
| 22 | $allowedSearches = $this->allowedSearches->implode(', '); |
|
| 23 | $message = "Given search(es) `{$unknownSearches}` are not allowed. Allowed search(es) are `{$allowedSearches}`."; |
|
| 24 | ||
| 25 | parent::__construct(Response::HTTP_BAD_REQUEST, $message); |
|
| 26 | } |
|
| 27 | ||
| 28 | public static function searchesNotAllowed(Collection $unknownSearches, Collection $allowedSearches) |
|
| 29 | { |
|
| 30 | return new static(...func_get_args()); |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||