Reputation: 29
$checkMethod = $request->method();
if (!$checkMethod) {
return redirect('todo_show');
} else {
echo "yes";
}
if request is not post then how can i redirect to another route. This error occured "The GET method is not supported for this route. Supported methods: POST".
Upvotes: 0
Views: 392
Reputation: 34688
Change your route Route::post...
to Route::any...
or Route::match(['GET', 'POST')]…
And as per Laravel documentation you can check this request method on your controller :
$method = $request->method();
if ($request->isMethod('post')) {
return redirect('todo_show');
} else {
echo "yes";
}
Upvotes: 1