thinkphp使用模型model批量更新数据库切换fastadmin
示例
控制器
public function is_shenghe()
{
$post = $this->request->post();
$ids = empty($post['ids']) ? [] : $post['ids'];
$is_shenghe = (int)request()->request("is_shenghe");
if (!$ids) {
$this->error("请选择要操作的数据");
}
$this->model->where('id', 'in', $ids)->where('product_name', '<>', '')->update(['is_shenghe' => $is_shenghe]);
$this->success("批量操作成功");
}
视图列表index.html
<a class="btn btn-success is_shenghe btn-disabled disabled" href="javascript:;" data-params="1"><i class="fa fa-eye is_shenghe"></i> 批准</a>
<a class="btn btn-success