| @@ 8-32 (lines=25) @@ | ||
| 5 | use Illuminate\Http\Response; |
|
| 6 | use Illuminate\Support\Collection; |
|
| 7 | ||
| 8 | class InvalidIncludeQuery extends InvalidQuery |
|
| 9 | { |
|
| 10 | /** @var \Illuminate\Support\Collection */ |
|
| 11 | public $unknownIncludes; |
|
| 12 | ||
| 13 | /** @var \Illuminate\Support\Collection */ |
|
| 14 | public $allowedIncludes; |
|
| 15 | ||
| 16 | public function __construct(Collection $unknownIncludes, Collection $allowedIncludes) |
|
| 17 | { |
|
| 18 | $this->unknownIncludes = $unknownIncludes; |
|
| 19 | $this->allowedIncludes = $allowedIncludes; |
|
| 20 | ||
| 21 | $unknownIncludes = $unknownIncludes->implode(', '); |
|
| 22 | $allowedIncludes = $allowedIncludes->implode(', '); |
|
| 23 | $message = "Given include(s) `{$unknownIncludes}` are not allowed. Allowed include(s) are `{$allowedIncludes}`."; |
|
| 24 | ||
| 25 | parent::__construct(Response::HTTP_BAD_REQUEST, $message); |
|
| 26 | } |
|
| 27 | ||
| 28 | public static function includesNotAllowed(Collection $unknownIncludes, Collection $allowedIncludes) |
|
| 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 InvalidSortQuery extends InvalidQuery |
|
| 9 | { |
|
| 10 | /** @var \Illuminate\Support\Collection */ |
|
| 11 | public $unknownSorts; |
|
| 12 | ||
| 13 | /** @var \Illuminate\Support\Collection */ |
|
| 14 | public $allowedSorts; |
|
| 15 | ||
| 16 | public function __construct(Collection $unknownSorts, Collection $allowedSorts) |
|
| 17 | { |
|
| 18 | $this->unknownSorts = $unknownSorts; |
|
| 19 | $this->allowedSorts = $allowedSorts; |
|
| 20 | ||
| 21 | $allowedSorts = $allowedSorts->implode(', '); |
|
| 22 | $unknownSorts = $unknownSorts->implode(', '); |
|
| 23 | $message = "Given sort(s) `{$unknownSorts}` is not allowed. Allowed sort(s) are `{$allowedSorts}`."; |
|
| 24 | ||
| 25 | parent::__construct(Response::HTTP_BAD_REQUEST, $message); |
|
| 26 | } |
|
| 27 | ||
| 28 | public static function sortsNotAllowed(Collection $unknownSorts, Collection $allowedSorts) |
|
| 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 InvalidAppendQuery extends InvalidQuery |
|
| 9 | { |
|
| 10 | /** @var \Illuminate\Support\Collection */ |
|
| 11 | public $appendsNotAllowed; |
|
| 12 | ||
| 13 | /** @var \Illuminate\Support\Collection */ |
|
| 14 | public $allowedAppends; |
|
| 15 | ||
| 16 | public function __construct(Collection $appendsNotAllowed, Collection $allowedAppends) |
|
| 17 | { |
|
| 18 | $this->appendsNotAllowed = $appendsNotAllowed; |
|
| 19 | $this->allowedAppends = $allowedAppends; |
|
| 20 | ||
| 21 | $appendsNotAllowed = $appendsNotAllowed->implode(', '); |
|
| 22 | $allowedAppends = $allowedAppends->implode(', '); |
|
| 23 | $message = "Given append(s) `{$appendsNotAllowed}` are not allowed. Allowed append(s) are `{$allowedAppends}`."; |
|
| 24 | ||
| 25 | parent::__construct(Response::HTTP_BAD_REQUEST, $message); |
|
| 26 | } |
|
| 27 | ||
| 28 | public static function appendsNotAllowed(Collection $appendsNotAllowed, Collection $allowedAppends) |
|
| 29 | { |
|
| 30 | return new static(...func_get_args()); |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||