MethodNotAllowedHttpException laravel 4.2 error


MethodNotAllowedHttpException laravel 4.2 error

这里是我的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() }}

我做错了什么?

用这个代替,将$contact->id作为参数传递给表单,而不是直接在URL中传递:

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