在fastadmin中,删除表格中,一行数据应该如何实现,以下则是实现方法,如有错误可评论指正
/**
* 删除
*/
public function del($ids = "")
{
if (!$this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
$ids = $ids ? $ids : $this->request->post("ids");
$row = $this->model->get($ids);
$this->modelValidate = true;
if (!$row) {
$this->error(__('No Results were found'));
}
//“student”为表名,“Id”为表中的id表头。需要进行相对应的修改
$data = db('student')->where('Id',$row['Id'])->delete();
// Auth::where()->delete($row['id']);
$data ? $this->success() : $this->error();
// $this->success();
}
}