We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
HttpResponseException
1 parent ef43c3e commit 228d334Copy full SHA for 228d334
src/ResourceRequest.php
@@ -2,7 +2,10 @@
2
3
namespace HDSSolutions\Laravel\API;
4
5
+use Illuminate\Contracts\Validation\Validator;
6
use Illuminate\Foundation\Http\FormRequest;
7
+use Illuminate\Http\Exceptions\HttpResponseException;
8
+use Illuminate\Http\Response;
9
use RuntimeException;
10
11
class ResourceRequest extends FormRequest implements Contracts\ResourceRequest {
@@ -49,4 +52,11 @@ protected function destroy(): array {
49
52
return [];
50
53
}
51
54
55
+ protected function failedValidation(Validator $validator): void {
56
+ throw new HttpResponseException(response()->json([
57
+ 'message' => 'Request validation failed',
58
+ 'data' => $validator->errors(),
59
+ ], Response::HTTP_UNPROCESSABLE_ENTITY));
60
+ }
61
+
62
0 commit comments