samedi 11 novembre 2017

MethodnotallowedExeption when I patch from previous post route

First of all its not the entry level error that I am sending a request to a wrong route verb.

My case its this: I have a post route

Route::post('/user/edit', 'UserController@edit');

when I hit this route I have a random form to update a specific user details. The thing is when I submit the form it goes to route:

Route::put('user/update','UserController@update'); 

All working. But I want to add a lil bit of validation so user does not send me the same existing data so I added a validation for that :

  if($this->method() =='PUT'){
        return [
            'name'=>'required|unique:users,name'
        ];
    }

The thing is when validation kicks in it redirects back with the messages I can catch the session manually and I see that validation is working, and it should send back to first route but I get a method not allowed exception. I assume validation base method sends a GET request back ?

Any idea how to come over this issue >



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

Aucun commentaire:

Enregistrer un commentaire