Laravel 4.2 NotAllowedHttpException Method on Dispose
I'm new to Laravel, so I have a project, simple CRUD, but the delete method doesn't work when I try to delete data, and I really don't know why. This is mistake:
Mistake:
throw new MethodNotAllowedHttpException($others);
Controller:
public function destroy($id)
{
$project = Project::find($id);
if($project->user_id==Auth::id()) {
$project->delete();
return Redirect::to('/');
} else {
Session::flash('message', 'You can't delete this!');
return Redirect::to('/');
}
}
View:
{{Form::open(array('url' => 'project/destroy/'.$p->id, 'method' => 'DELETE'))}}
{{Form::submit("Delete", array('class' => 't2tButton text-center'))}}
{{Form::close()}}
Routes
Route::post('/project/destroy/{id}', "ProjectController@destroy");
+3
source to share