How to route GET and POST for same pattern in Laravel?

You can combine all HTTP verbs for a route using:

Route::any('login', 'AuthController@login');

This will match both GET and POST HTTP verbs. And it will also match for PUT, PATCH & DELETE.


See the below code.

Route::match(array('GET','POST'),'login', 'AuthController@login');

The docs say...

Route::match(array('GET', 'POST'), '/', function()
{
    return 'Hello World';
});

source: http://laravel.com/docs/routing


Route::any('login', 'AuthController@login');

and in controller:

if (Request::isMethod('post'))
{
// ... this is POST method
}
if (Request::isMethod('get'))
{
// ... this is GET method
}
...