MethodNotAllowedHttpException laravel 4.2错误

时间:2015-09-15 11:24:51

标签: php laravel-4 migration

这是我的ContactController.php:

public function destroy($id){
    $contact = Contact::find($id);
    $contact->delete();
    return Redirect::to('http://localhost:8000/contactsview');
}

这是我的rountes.php

Route::delete('/contactsview/destroy/{id}', array('uses'=>'ContactController@destroy'));

这是我的index.blade.php:

{{ Form::open(array('url'=>'/contactsview/delete/'.$contact->id, 'method'=>'DELETE', 'style'=>'display:inline;')) }}
<!-- {{ Form::hidden('id', $contact->id) }} -->
{{ Form::submit('Delete') }}
{{ Form::close() }}

我做错了什么?

1 个答案:

答案 0 :(得分:0)

请尝试使用此表单,将$contact->id作为参数传递,而不是直接传递到URL中:

{{ Form::open(array('method' => 'DELETE', 'action' => array('ContactController@destroy', $contact->id )) }}