Created
November 22, 2016 03:15
-
-
Save cuonghuynh/9cc0d0f3eb390d416ebfb5a1a9e318bd to your computer and use it in GitHub Desktop.
Turning off Validation Redirects
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
<?php | |
namespace App\Http\Requests; | |
use Illuminate\Http\JsonResponse; | |
use Illuminate\Foundation\Http\FormRequest; | |
use Illuminate\Contracts\Validation\Validator; | |
use Illuminate\Http\Exception\HttpResponseException; | |
abstract class BaseRequest extends FormRequest | |
{ | |
/** | |
* Handle a failed validation attempt. | |
* | |
* @param \Illuminate\Contracts\Validation\Validator $validator | |
* @return mixed | |
*/ | |
protected function failedValidation(Validator $validator) | |
{ | |
throw new HttpResponseException($this->response([ | |
'errors' => $this->formatErrors($validator) | |
])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment