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 >
Yes, this is how validation works. When data is invalid there is made redirection to form using obviously GET method.
In general you shouldn't display forms in POST action. Usually what you should do is redirecting to some other route that is available via GET. This is done usually also for multi-step forms:
GET step1 -> POST step 1 -> GET step 2 -> POST step 2 and so on.
So you should do exactly the same in your case to make it work with validation.