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

Deadmandream's avatar

The DELETE method is not supported for this route. Supported methods: GET, HEAD.

Hello i'm trying to create a CRUD webstite but when i'm in delete i get this error.

Here is my view

  <form action="{{ url('/setting/destroy'), $row->id }}" method="POST"></form>
                                    <td>
                                        @csrf
                                        @method('delete')
                                        <button class="btn btn-danger" type="submit"> Delete</button>
                                    </td>
                                </form>

My route

    Route::delete('/setting/destroy/{id}', [ItemController::class, 'destroy']);

my controller

 /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy(ItemPage $itemPage, $id)
    {
        //
        $itemPage->delete();

        if($itemPage){
            return redirect('/setting_div')->with('success', 'Item berhasil dihapus ');
         }else{
             return redirect('/setting_div')->with('error', 'Item succesfully deleted');
         } 
    }

I want to try to change the form from URL into Route, but when i'm trying to use route it always said that "Route is not defined"

0 likes
6 replies
rodrigo.pedra's avatar

You should concatenate the $row->id to the route path:

<form action="{{ url('/setting/destroy/' . $row->id) }}" method="POST">

EDIT: simplified route concatenation

tykus's avatar

This {{ url('/setting/destroy'), $row->id }} is not valid Blade syntax, it should be:

{{ url('/setting/destroy', $row->id) }}

Also, route wildcard should match the typehinted controller action argument if you want Route Model binding:

Route::delete('/setting/destroy/{itemPage}', [ItemController::class, 'destroy']);

Last, the controller action should expect a single parameter itemPage:

public function destroy(ItemPage $itemPage)
rodrigo.pedra's avatar

@tykus , as they are using the url helper and not the route helper, I think they need to concatenate the parameter on the path:

{{ url('/setting/destroy/' . $row->id) }}

@deadmandream consider @tykus suggestion on your controller's method signature.

rodrigo.pedra's avatar

@tykus thanks for the heads up.

As I usually use the route helper, I assumed additional parameters to the url helper would be appended as query strings.

Thanks again!

Deadmandream's avatar

Firstly thank you guys for answering my question

So i'm using @tykus suggestion but i'm still getting the same error i already updated the Blade syntax and i also edited the controller

here is my updated view

@foreach ($itempage as $row) 
                            <tr>
                                <td><input type="checkbox" name="" id=""></td>
                                <td>{{ ++$i }}</td>
                                <td>{{ $row->judul }}</td>
                                <td><a href="#"><i class="fa fa-plus" aria-hidden="true"></i></a></td>
                                <td><label class="switch"><input type="checkbox"><span class="slider round"></span></label></td>
                                    <td><button class="btn btn-success">Edit</button></td>
                                <form action="{{ url('/setting/destroy', $row->id ) }}" method="POST">
                                    <td>
                                        @csrf
                                        @method('delete')
                                        <button class="btn btn-danger" type="submit"> Delete</button>
                                    </td>
                                </form>
                            </tr>
                        @endforeach   

My Route

    Route::get('/setting/id',[ItemController::class, 'index'])->name('settingDiv');
    Route::delete('/setting/destroy/{itempage}', [ItemController::class, 'destroy']);

and lastly my Controller

    public function destroy(ItemPage $itempage)
    {
        //
        $itempage->delete();

        if($itempage){
            return redirect('/setting_div')->with('success', 'Item berhasil dihapus ');
         }else{
             return redirect('/setting_div')->with('error', 'Item succesfully deleted');
         } 
    }

Please or to participate in this conversation.