这是我的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() }}
我做错了什么?
答案 0 :(得分:0)
请尝试使用此表单,将$contact->id
作为参数传递,而不是直接传递到URL中:
{{ Form::open(array('method' => 'DELETE', 'action' => array('ContactController@destroy', $contact->id )) }}