MethodNotAllowedHttpException in RouteCollection.php - Laravel 5.2

2

Developing an application using Laravel 5.2, PHP7.0, Apache2 and CentOS 7, I'm having the following error: MethodNotAllowedHttpException .

On the local server it works normally ... when I publish to the production server the error occurs, it follows the screen:

Routes:

I'mtryingtoreach(POST)theURL:/en/create

Intheroutefile:

Route::group(['prefix'=>'es'],function(){Route::group(['middleware'=>'auth'],function(){Route::post('create','SearchController@create');});});

View:

<h1>Create</h1><formmethod="POST" action="/es/create/" enctype="application/x-www-form-urlencoded">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
    <input type="text" name="index">
    <button type="submit">CREATE</button>        
</form>

I did not put the controller here because it does not even get to the controller ... on the route.

I have tried the enctype="application / x-www-form-urlencoded" as per some posts ... but it did not work.

Would anyone have a suggestion?

Thank you!

Q.: I found several posts in English, but none with the solution I need.

    
asked by anonymous 19.06.2016 / 22:40

2 answers

2
The View , action tag of the form tag should include the full path of the route:
22.06.2016 / 13:03
-1

Another alternative would be to use the helper action, below this your changed code.

Instead:

<input type="hidden" name="_token" value="{{ csrf_token() }}">

Do this:

{{ csrf_field() }}

And here your code changed:

<h1>Create</h1>
<form method="POST" action="{{ action('SearchController@create') }}" enctype="application/x-www-form-urlencoded">
    {{ csrf_field() }}
    <input type="text" name="index">
    <button type="submit">CREATE</button>        
</form>
    
22.06.2016 / 22:47