Skip to main content

The POST method is not supported for this route.

 


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

Popular posts from this blog

Laravel Vuejs Basic Setup

In this article we will see how to setup vue with laravel. 1) Create a laravel project: laravel new laravue 2) In web.php create a temporary route:  Route :: get ( '/test' ,  function  () {      return   view ( 'welcome' ); }); So, when you will see the welcome page once you hit the  http://laravue.test/test  url. 2) In terminal run:  npm install 3) npm install vue (In package.json file you will see that vue dependency has been added successfully) 4) Now go to resources -> js -> app.js file. Here we will have to load the vue. write the following lines in app.js.  require ( './bootstrap' ); window . Vue  =  require ( 'vue' ); const   app  =  new   Vue ({      el :   '#app' }); (Here, vue js will execute and control anything that will be inside the app id. So, for our example  let's put the app id inside the welcome view). So, inside welcome.blade.php 's body...