Route Post is not being recognized (Laravel)

1

Well, I'm still new to using Laravel 5, but I have a problem with Routes that can not find a solution anywhere (just the same problem Here and no feasible solution)

I'll explain in the routes.php file when I try to define a route using POST it is not recognized!

Among other routes I have this:

Route::post('guarda-terreno',[
'as'=>'guardaTerrenoPost',
'uses'=>'TerrenoController@store',]);

This route should receive data from a form. When I try to see the routes defined: php artisan route:list this route does not appear in the listing. More weird, is that if I switch to

Route::get('guarda-terreno',[
'as'=>'guardaTerrenoPost',
'uses'=>'TerrenoController@store',]);

It already appears in the list!

I've tried this:

Route::post('guarda-terreno', 'TerrenoController@store');

And you can not!

If you use Route::any('guarda-terreno', 'TerrenoController@store'); it already registers all | GET|HEAD|POST|PUT|PATCH|DELETE | methods when I only wanted POST!

What am I not seeing here?!

    
asked by anonymous 17.03.2015 / 01:31

2 answers

0

I do not know why this is not working, I advise you to open an issue here reporting the error.

Another way to use the route post is by function match, passing 'post' into an array in the first parameter

Route::match(['post'],'guarda-terreno',[ 
'as'=>'guardaTerrenoPost', 
'uses'=>'TerrenoController@store',]
);

There is no difference between one function or another in relation to performance, so I advise you to use this one in your project

    
17.03.2015 / 15:48
0

Why do you need this ,] in the end? The problem may be because there is already another route to this action, TerraController @ store which is also post, maybe you have configured a Route :: resource and you are trying to create a Route :: post, so it should be generating conflict. But if it is not, try to remove this ,] . The correct would be:

Route::post('guarda-terreno',[
      'as'=>'guardaTerrenoPost',
      'uses'=>'TerrenoController@store'
   ]
);
    
18.03.2015 / 00:32