model = model('User'); } /** * 查看 */ public function index() { //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); $parent_id = $this->request->request('parent_id'); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); if($parent_id > 0) { $whereExt = []; $whereExt["pre_userid"] = $parent_id; } $list = $this->model ->with(['noble']) ->where($where) ->where($whereExt) ->order($sort, $order) ->paginate($limit); foreach ($list as $k => $v) { $v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname); $v->hidden(['password', 'salt']); } $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } return $this->view->fetch(); } /** * 添加 */ public function add() { if ($this->request->isPost()) { $this->token(); } return parent::add(); } /** * 编辑 */ public function edit($ids = null) { if ($this->request->isPost()) { $this->token(); } $row = $this->model->get($ids); $this->modelValidate = true; if (!$row) { $this->error(__('No Results were found')); } return parent::edit($ids); } /** * 删除 */ 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')); } Auth::instance()->delete($row['id']); $this->success(); } }