Created
October 4, 2018 09:36
-
-
Save hungthai1401/406e44947b696db44c86d0fbbb7e2d77 to your computer and use it in GitHub Desktop.
Form request return json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Illuminate\Validation\ValidationException; | |
use Illuminate\Contracts\Validation\Validator; | |
use Illuminate\Http\Exceptions\HttpResponseException; | |
/** | |
* Handle a failed validation attempt. | |
* | |
* @param \Illuminate\Contracts\Validation\Validator $validator | |
* @return void | |
* | |
* @throws HttpResponseException | |
*/ | |
protected function failedValidation(Validator $validator) : void | |
{ | |
$errors = (new ValidationException($validator))->errors(); | |
throw new HttpResponseException(format_response(ResultCode::ERROR, null, $errors)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment