Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions app/admin/traits/Curd.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public function add()
/**
* @NodeAnotation(title="编辑")
*/
public function edit($id)
public function edit()
{
$row = $this->model->find($id);
$row = $this->model->find($this->request->param($this->model->getPk()));
empty($row) && $this->error('数据不存在');
if ($this->request->isAjax()) {
$post = $this->request->post();
Expand All @@ -99,9 +99,9 @@ public function edit($id)
/**
* @NodeAnotation(title="删除")
*/
public function delete($id)
public function delete()
{
$row = $this->model->whereIn('id', $id)->select();
$row = $this->model->whereIn($this->model->getPk(), $this->request->param($this->model->getPk()))->select();
$row->isEmpty() && $this->error('数据不存在');
try {
$save = $row->delete();
Expand Down Expand Up @@ -131,7 +131,7 @@ public function export()
$list = $this->model
->where($where)
->limit(100000)
->order('id', 'desc')
->order($this->model->getPk(), 'desc')
->select()
->toArray();
$fileName = time();
Expand All @@ -145,12 +145,12 @@ public function modify()
{
$post = $this->request->post();
$rule = [
'id|ID' => 'require',
'field|字段' => 'require',
'value|值' => 'require',
$this->model->getPk().'|主键' => 'require',
'field|字段' => 'require',
'value|值' => 'require',
];
$this->validate($post, $rule);
$row = $this->model->find($post['id']);
$row = $this->model->find($post[$this->model->getPk()]);
if (!$row) {
$this->error('数据不存在');
}
Expand Down