getList(); return $this->fetch('index', compact('list')); } /** * [add] * 添加资质 * @Author: Yeshihao * @DateTime: 2024/11/26 14:56 * @return array|bool|mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function add() { $model = new CertificateModel; if (!$this->request->isAjax()) { $category = CertificateCategoryModel::getAll(); return $this->fetch('add', compact('category')); } // 新增记录 if ($model->add($this->postData())) { return $this->renderSuccess('添加成功', url('content.certificate/index')); } return $this->renderError($model->getError() ?: '添加失败'); } /** * 更新文章 * * @param $article_id * @return array|mixed * @throws \think\exception\DbException */ public function edit($id) { // 文章详情 $model = CertificateModel::detail($id); if (!$this->request->isAjax()) { $category = CertificateCategoryModel::getAll(); return $this->fetch('edit', compact('model', 'category')); } // 更新记录 if ($model->edit($this->postData())) { return $this->renderSuccess('更新成功', url('content.certificate/index')); } return $this->renderError($model->getError() ?: '更新失败'); } /** * [delete] * * @Author: Yeshihao * @DateTime: 2024/11/28 10:08 * @param $id * @return array|bool * @throws \think\exception\DbException */ public function delete($id) { // 文章详情 $model = CertificateModel::detail($id); if (!$model->setDelete()) { return $this->renderError($model->getError() ?: '删除失败'); } return $this->renderSuccess('删除成功'); } }