The POST method is not supported for this route.
While updating a form you might face this error.
That happens because of your form action method or the web route of
that action.
So, lets see the solutions.
1) If the method is update and the form action is like this:
<form action="{{route('invoice.update', $invoice->id)}}" method="POST" enctype="multipart/form-data">
@csrf
</form>
and route of this:
Route::patch('invoice/{id}','InvoiceController@update')->name('invoice.update');
Here, from the route we can see that this is a patch method. so,
for patch method we need to write {{ method_field('patch') }}
between form. Example:
<form action="{{route('invoice.update', $invoice->id)}}" method="POST" enctype="multipart/form-data">
@csrf
{{ method_field('patch') }}
</form>
2) If we change the Route::patch to Route::post it will also work. In that case
we don't need to write {{method_field('patch')}}.
Comments
Post a Comment