public function actionEditservice() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new ArticleForm(); $form->setScenario('service'); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$employIndex_url); return; } //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = (new Article())->updateArticleByService($id, $form->title, $form->useId, $form->keywords, $form->pic, $form->content); // $isSuccess = (new Employ())->updateEmploy($id,$form->department,$form->employName,$form->address,$form->employCode,$form->group,$form->count,$form->money,$form->type,$form->category,$form->description,$form->sendEmail,$form->status); if ($isSuccess) { Yii::$app->session->setFlash(Variable::$flash_success, '服务项修改成功'); $this->redirect(Variable::$serviceIndex_url); return; } else { Yii::$app->session->setFlash(Variable::$flash_error, '服务项修改失败,请重试'); return; } } $articleModel = Article::findOne($id); $form->title = $articleModel->title; $form->keywords = $articleModel->keywords; $form->pic = $articleModel->pic; $form->useId = $articleModel->useId; $form->content = $articleModel->content; return $this->render(Variable::$editService_view, ['model' => $form, 'articleModel' => $articleModel]); }
public function actionAddarticle() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new ArticleForm(); $articleModel = new Article(); $articleCatModel = ArticleCategory::find()->all(); //添加 $form->setScenario('create'); if ($form->load($req->post()) && $form->validate()) { if ($articleModel->addAerticle($form->title, $form->keywords, $form->categoryId, $form->content, $form->status, $form->isTop, $form->description, $form->pic)) { $this->redirect(Variable::$articleManger_url); return; } } return $this->render(Variable::$addArticle_view, ['model' => $form, 'articleModel' => $articleModel, 'articleCatModel' => $articleCatModel]); }
public function actionEditliftobject() { $user = new AdminUser(); if (!$user->checkUserIsLogin()) { $this->redirect(Variable::$home_url); return; } $req = Yii::$app->request; //创建一个请求对象 $form = new ArticleForm(); $form->setScenario('editLiftObject'); $id = trim($req->get('id')); if (!is_numeric($id) || $id == 0) { $this->redirect(Variable::$liftObject_url); return; } $articleModel = Article::findOne($id); $form->categoryId = $articleModel->categoryId; //修改 if ($form->load($req->post()) && $form->validate()) { $isSuccess = (new Article())->updateArticleContent($id, $form->content); if ($isSuccess) { Yii::$app->session->setFlash(Variable::$flash_success, '资料更新成功'); } else { Yii::$app->session->setFlash(Variable::$flash_error, '资料更新失败,请刷新重试'); } // $this->redirect(Yii::$app->urlManager->createUrl([Variable::$showLiftObject_url,'id'=>$id])); } $articleModel = Article::findOne($id); $form->content = $articleModel->content; $form->title = $articleModel->articleCat->name; return $this->render(Variable::$editLiftObject_view, ['model' => $form, 'articleModel' => $articleModel]); }
/** * Deletes an existing Article model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $model = new ArticleForm($id); $model->deleteArticle(); $session = Yii::$app->session; $session->setFlash('info', Yii::t('back', 'Article successfully deleted!')); if ($this->_category) { return $this->redirect(['category/articles', 'id' => $this->_category->id]); } else { return $this->redirect(['index']); } }