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 (current version) :

<form action="" method="POST">
   
   
   <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~

edit: to further help the effort, here's the complete error log Error log, in Google Chrome



via Kevin fu

Advertisement