Monday, March 13, 2017

Laravel 5.4 "MethodNotAllowedHttpException" (Basic Task List)

i was trying to follow this tutorial on Laravel, even though most of the code & directories there were outdated, i managed to make the "Add Task" and also The Form to show up after a few errors.

now the problem, the delete button. when i click on it, it shows a "MethodNotAllowedHttpException". i changed the source code to match the newest version of Laravel.

my form :

<form action="" method="DELETE">
   
   
   <button type="submit" class="btn btn-danger">
     <i class="fa fa-btn fa-trash"></i>Delete
   </button>
</form>

my route :

Route::delete('/task/{id}', function ($id) { Task::findOrFail($id)->delete(); return redirect('/'); });

i've been trying to fix this for 4 hours now, changing the methods of my route and form; but to no avail. this is my first question on this site, sorry if there's something wrong in this question.

thanks~



via Kevin fu

Advertisement