FormRequest.php 458 B

12345678910111213141516171819202122
  1. <?php
  2. namespace App\Http\Requests;
  3. use Dingo\Api\Http\FormRequest as BaseFormRequest;
  4. use Illuminate\Http\Exceptions\HttpResponseException;
  5. class FormRequest extends BaseFormRequest
  6. {
  7. public function authorize()
  8. {
  9. return true;
  10. }
  11. public function failedValidation($validator)
  12. {
  13. $error= $validator->errors()->all();
  14. throw new HttpResponseException(response()->json(['code'=>202,'message'=>$error[0]]));
  15. }
  16. }