Route Post is not being recognized (Laravel)

Asked

Viewed 1,023 times

1

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

Let me explain, in the Routes.php file when I try to define a route using POST she 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 change to

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

she’s already on the list!

I’ve tried it like this:

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

And it doesn’t work!

UseRoute::any('guarda-terreno', 'TerrenoController@store'); he already records me all the methods | GET|HEAD|POST|PUT|PATCH|DELETE |when I wanted only the POST!

What am I not seeing here?!

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

  • I haven’t tried that before... This has already worked, I only have a POST route for the "store" method instead of 6! Is there any particular reason why Route::post('ground guard', 'Terrenocontroller@store'); not give and your solution works? Thanks for the help!

  • is feathers with that route that is giving this problem ?

  • gives me the same problem with all Post routes... regardless of model and method! As it is a "rare" problem (because I did not find any solution easily) I will assume that it is my problem and changed some configuration where it should not! Your solution works, so I will adopt it, in a new "clean" protection there I check if it works the POST again! Thanks for the help!

2 answers

0


I don’t know why it’s not working, I would advise you to open an Issue here reporting the error.

Another way to use route post is through Function match, passing 'post' within 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 using this in your project

0

Why do you need this ,] in the end? The problem may be because there is already another route for this action, Terrenocontroller@store which is also post, maybe you have set up a Route::Source and are trying to create a Route::post, then you may be generating conflict. But if it’s nothing like that, try removing that ,]. The right thing would be:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.