Search code examples
routeslaravel-5put

Laravel 5. Dont work put and delete methods


Today stopped working DELETE and PUT methods with link_to_route

MethodNotAllowedHttpException in RouteCollection.php

Route:

Route::put('inits/{init_id}/publication', ['as' => 'init.publication', 'uses' =>'Inits\InitsController@putPublicationInit']);

Blade:

{!! link_to_route('init.publication',
        'Publication',
        $init->id,
        ['class' => 'btn btn-control gray-lighter',
        'data-method' => 'put',
        'data-token' => csrf_token()]
) !!}

DELETE methods leads to GET. What is the problem?


Solution

  • You cannot have a link that will make a POST request. All Links are GET requests. Use form or javascript to trigger a POST/DELETE/PUT request when the link is clicked.

    Here's a question with an example of how to accomplish that.