Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jmvdholst's avatar

Can't figure out Route::delete to work (no message error)

When I use in routes/web.php

Route::delete('/pim_products/delete', 'PimProductController@destroy');

then I get a MethodNotAllowedHttpException with a NO MESSAGE signal below it.

Most of the time this is caused by a Route mismatch. Sometimes in names, paths, etc but also the HTML Method could not be allowed.

In this case I was able to fix it by replacing Route::delete by Route::any

Route::any('/pim_products/delete', 'PimProductController@destroy');

I figured from reading the docs on routing, that by using any, I could at least take the Method out of the equation. Now that I did, it is imminent that the method is the problem.

But I have no clue why the Route::delete method was not allowed here, and what method is actually making my code work instead.

Can anyone show me the way?

Many thanks from a enthusiastic Laravel newby.

0 likes
3 replies
Cronix's avatar
Cronix
Best Answer
Level 67

I think you can only hit a DELETE route via a form post, because it needs to issue a delete verb.

<form method="post" action="/pim_products/delete">
    @method('DELETE')
    @csrf
    // fields
</form>

It won't work with anchor tags, etc, because those all issue a GET request. If course you could do it via ajax as well since you can set the HTTP verb there.

So if you want to use a delete in an anchor (<a href="/pim_products/delete">Delete Item</a>) then it would have to be a Route::get().

Also, you should probably be passing the ID of the thing you want to delete.

jmvdholst's avatar

Many thanks @Cronix

I think I got it.

This was my form code.

    <form method="DELETE" action="/pim_products/delete" class="form-control-lg">
        {{ csrf_field() }}
        <button class="btn btn-primary bg-danger">
            Delete info from database
        </button>
    </form>

When I updated to your suggestions, the delete method worked. Makes it more clean. Also learned a new trick on the side (@csrf)

Really great, lost many hours trying to figure this one out. Now I can continue to build something amazing.

Please or to participate in this conversation.