I have a route that supports PUT:
Route::put('/products/{id}/cancel/', 'ProductController@cancel')->where('id', '[0-9]+');
After the Controller updates the state of the product it should redirect to another route:
return redirect('products')->with('success', 'Produto cancelado');
that points to
Route::get('/products', 'ProductController@list')->name('products');
All is working until the Redirect. The product is updated but the redirect gives a method not supported error:
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
The PUT method is not supported for this route. Supported methods: GET, HEAD
I've also tried the following redirects:
return redirect('/products/')->with('success', 'Produto cancelado');
and
return redirect()->route('products')->with('success', 'Produto cancelado');
How is the method PUT passed? Should I explicitly invoke the GET method in the redirect?
How should I solve this?
EDIT: I'm sending the PUT from a HTTPrequest. So I'm returning to the JS function. I want to forward to a view that accepts the with->.
EDIT2: I can return a view but it only appears on the network>preview of the Developer Tools.
return view('pages.products')->with('success', 'Produto cancelado');
But I need it in the window obviously.
I could redirect in the js but that way I miss showing the flash messages in the partial blade.
I don't know what to do.
Thanks