megahunt.test/app/Http/Requests/RestRequest.php

18 lines
435 B
PHP
Raw Permalink Normal View History

2024-08-30 00:46:03 +02:00
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;
class RestRequest extends FormRequest
{
protected function failedValidation(Validator $validator)
{
$exception = $validator->getException();
throw new HttpResponseException(response()->json($validator->errors(), 422));
}
}