I am validating form with formRequest
, I have defined $redirect
. Now I want to handle validation error in $redirect
function.
I am able to create the json with error message from formRequest but without $redirect.
Here is my code,
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
use Response;
class CreateUserRequest extends Request {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required'
];
}
public function messages(){
return [
'email.required' => 'Er, you forgot your email address!'
];
}
public function response(array $errors)
{
return Response::json($errors, 400);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With