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

horsford's avatar

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

I get this error when updating the product, I use laravel 7.3, the browsers do not read the patch / put methods and I added the @method directive to the form and I did it using method_fields also but it keeps generating the same error.

edit.blade.php

@section('contenido')
            <div class="content-fluid">

                <div class="row justify-content-center">
                <form action="{{ route('aluminio.store', $producto->id) }}" method="post" enctype="multipart/form-data">
                  @csrf
                  @method('PATCH')
                      <div class="col-10">
                          <h1 class="font-weight-bold my-3">Editar Producto</h1>
                          <div class="form-group">
                          <label  for="tipologia" class="control-label font-weight-bold">Tipología</label>
                          <input type="text" class="form-control" name="tipologia" id="tipologia" value="{{ $producto->tipologia }}">
                          </div>
                          <div class="form-group">
                          <label  for="caracteristicas" class="control-label font-weight-bold">Características</label><br>                            
                          <textarea name="caracteristicas" id="caracteristicas" cols="42" rows="5">{{ $producto->caracteristicas }}</textarea>
                          </div>
                          <div class="form-group">
                          <button class="btn btn-primary" type="submit">Actualizar</button>
                         </div>                       
                      </div>                       
                    </form>                 
                </div>
            </div>
            @endsection

AluminioController.php

public function edit($id){
        $producto = Aluminio::find($id);
        return view('aluminio.edit', compact('producto'));
    }

    public function update(Request $request, $id){

        $producto = Aluminio::find($id);
        $producto-> tipologia = $request->tipologia;
        $producto-> caracteristicas = $request->caracteristicas;
        $producto-> ventajas = $request->ventajas;
        $producto-> desventajas = $request->desventajas;
        $producto-> foto = $request->foto;
        $producto-> nota = $request->nota;
        $producto->update();

        return redirect(route('aluminio'));
    }

web.php

Route::get('aluminio/{id}/edit', 'AluminioController@edit')->name('aluminio.edit');
Route::patch('aluminio/{id}', 'AluminioController@update')->name('aluminio.update');
0 likes
8 replies
tykus's avatar
tykus
Best Answer
Level 104

You are submitting to 'aluminio.store', not 'aluminio.update'; change the route in the form action:

<form action="{{ route('aluminio.update', $producto->id) }}" method="post" enctype="multipart/form-data">
    @csrf
    @method('PATCH')
3 likes
rizk191's avatar

@tykus

Getting an error for undefined $article.

This is my update function code - public function update(Request $req) { $data=article::find($req->id); $data->Title=$req->Title; $data->Description=$req->Description; $data->Image=$req->Image;

$data->save();

return redirect->route('Update-Article')->withSuccess('Updated Successfully');;

}

And this is the route that I've created - Route::patch('/Article-update/{id}','App\Http\Controllers\ArticleControlller@update')->name('Update-Article');

tykus's avatar

@Rishil19 don’t know how you expect me to diagnose that… start your own thread and share your code

rizk191's avatar

@tykus Actually I'm new to this so I don't know how to start a thread that's why I've posted my question in the comment box and I've also shared my code. could you please review it?

tykus's avatar

@rizk191 the error is. It coming from the code you shared

I don’t think you understand controller arguments / route wildcards.

Also, this idea of redirecting to a PATCH endpoint is not valid

rizk191's avatar

@tykus Yes, I'm new to Laravel, and the function code I've shared is written inside a controller

tykus's avatar

@rizk191 I understand where the code you shared is located, but it is not the source of the error message you shared

Consider taking the free Laravel from Scratch course here on Laracasts as a primer

horsford's avatar

If you are very right, thank you very much, I forgot to change it.

Please or to participate in this conversation.