model = new \app\admin\model\shopro\business_school\School; } public function index() { $this->request->filter(['strip_tags']); if ($this->request->isAjax()) { list($where, $sort, $order, $offset, $limit) = $this->custombuildparams(); $total = $this->model->where($where)->count(); $list = $this->model->where($where)->order($sort, $order)->limit($offset, $limit)->select(); return $this->success('商学院列表', null, ['total' => $total, 'rows' => $list]); } return $this->view->fetch(); } public function add() { if ($this->request->isPost()) { $params = $this->request->post('row/a'); if (empty($params['name'])) { $this->error('请输入商学院名称'); } $this->model->create($params); $this->success('添加成功'); } return $this->view->fetch(); } public function edit($ids = null) { $row = $this->model->get($ids); if (!$row) { $this->error('记录不存在'); } if ($this->request->isPost()) { $params = $this->request->post('row/a'); if (empty($params['name'])) { $this->error('请输入商学院名称'); } $row->save($params); $this->success('保存成功'); } $this->view->assign('row', $row); return $this->view->fetch(); } public function del($ids = null) { $row = $this->model->get($ids); if (!$row) { $this->error('记录不存在'); } $row->status = 'forbidden'; $row->save(); $this->success('操作成功'); } /** * 下拉选择 */ public function select() { $list = $this->model->where('status', 'normal')->field('id,name')->order('id desc')->select(); return $this->success('操作成功', null, $list); } }