我目前在我的视图中有一个表,其中有一个用于删除特定行的删除按钮,这是我的视图代码(仅限表格)
<table class="table table-striped table-hover" id="detailTable">
<thead>
<tr>
<th>Record ID</th>
<th>Student ID</th>
<th>Student Name</th>
<th>Parent Account ID</th>
<th>Guardian Name</th>
<th>Role</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach ($vpc as $key => $pc)
<tr>
<td>{{ $pc->GuardianChildID }}</td>
<td>{{ $pc->StudentID }}</td>
<td>{{ $pc->full_name }}</td>
<td>{{ $pc->ParentAccountID }}</td>
<td>{{ $pc->pfull_name }}</td>
<td>{{ $pc->Roles }}</td>
<td><button class="btn">{{ HTML::linkRoute('delpc','Delete', array($pc->GuardianChildID)) }}</button></td>
</tr>
@endforeach
</tbody>
</table>
然后在我的路线中我有这个代码来处理删除
Route::delete('viewa/{id}', array('as' => 'delpc', 'uses' => 'parentAcc@deleteAssignment'));
然后在我的控制器中这是执行删除的功能
public function deleteAssignment($id)
{
$deletegc = guardianChild::where('GuardianChildID', '=' , $id)
->delete();
return Redirect::to('viewa');
}
执行此操作时,我有一个方法不允许例外。任何想法我做错了什么?
答案 0 :(得分:1)
您需要一个表单才能使用删除操作。普通链接只能调用get动作。
{{ Form::open(array('route' => array('admin.pages.destroy', $page->id), 'method' => 'delete')) }}
<button type="submit" class="btn btn-danger btn-mini">Delete</button>
{{ Form::close() }}