Reputation: 158
POST method not working in laravel 5.4 , GET method is working same controller.
Route::get('/route','PostController@custon_function'); //working
Route::post('/route','PostController@custon_function'); //throw error
Upvotes: 0
Views: 532
Reputation: 2172
Option 1
You can combine GET
and POST
method with one route this way:
Route::match(array('GET','POST'),'/route','PostController@custom_function');
Option 2
Or you can use this alternative:
Route::any('/route', 'PostController@custom_function');
And within controller/function, you can check method name this way:
if (Request::isMethod('post'))
{
// ... this is POST method
}
if (Request::isMethod('get'))
{
// ... this is GET method
}
Upvotes: 1