## 批量刪除回收站的內容
1.View: 添加批量刪除按鈕,并指定刪除方法
> \themes\admin_simpleboot3\admin\recycle_bin\index.html
<button class="btn btn-danger btn-sm js-ajax-submit" type="submit"
data-action="{:url('RecycleBin/deleteAll')}" data-subcheck="true" data-msg="您確定刪除選中的數據嗎?">
批量{:lang('DELETE')}
</button>
2. Controller: 新增 deleteAll()
> \vendor\thinkcmf\cmf-app\src\admin\controller\RecycleBinController.php
public function deleteAll()
{
$param = $this->request->param();
if (isset($param['ids'])) {
$ids = $this->request->param('ids/a');
//通過ids查詢出清除的結果集
$result = Db::name('recycleBin')->where('id', 'in', $ids)->select();
if ($result) {
//遍歷得出文章IDS
foreach ($result as $key => $value) {
$wzids[]=$value['object_id'];
}
//文章表 刪除相關文章
$re = Db::name('portal_post')->where('id', 'in', $wzids)->delete();
if ($re) {
//關系表 刪除相關文章ID
Db::name('portal_category_post')->where('post_id', 'in', $wzids)->delete();
//標簽表 刪除相關文章ID
Db::name('portal_tag_post')->where('post_id', 'in', $wzids)->delete();
//回收站表 刪除相關ID
$res = Db::name('recycleBin')->where('id', 'in', $ids)->delete();
if ($res) {
$this->success("刪除成功!");
}
}
}
}
}