dimanche 31 janvier 2016

Laravel form request not redirecting correctly

I've just updated from laravel 5.1 to 5.2 and my form requests instead of redirecting to $redirect now throws me this error: "HttpResponseException" from here:

 * @param  \Illuminate\Contracts\Validation\Validator  $validator
 * @return mixed
 *
 * @throws \Illuminate\Http\Exception\HttpResponseException
 */
protected function failedValidation(Validator $validator)
{
    throw new HttpResponseException($this->response(
        $this->formatErrors($validator)
    ));

my form request code:

<?php 

namespace App\Http\Requests;

use Auth;

class ArticleEditRequest extends Request
{
    protected $redirect = '/';

    private $rules = ['message' => 'max:128'];

    public function rules()
    {
        return $this->rules;
    }

    public function authorize() 
    {
        return Auth::check();
    }
}

With laravel 5.1 it would just redirect to '/' with errors that then would be flashed to the user. How do I fix this? I tried overwriting failedValidation to redirect to $redirect, but then after failed validation it would still execute the controller code.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/20AeTYd
via IFTTT

Aucun commentaire:

Enregistrer un commentaire