Exemple #1
0
 public function actionLaw()
 {
     $infos = Article::findOne(['title' => '法律服务']);
     $model = UcenterMember::find()->where('id=' . Yii::$app->user->id)->one();
     $infos_rar = $this->Ucenter();
     //用户数据包
     return $this->render('law', compact("infos_rar", "model", "infos"));
 }
 public function deleteArticle($id)
 {
     $model = Article::findOne($id);
     if (!$model) {
         return false;
     }
     if ($model->delete()) {
         return true;
     }
     return false;
 }
Exemple #3
0
 public function updateArticleByService($id, $title, $useId, $keywords, $pic, $content)
 {
     $model = Article::findOne($id);
     if (!$model) {
         return false;
     }
     $model->content = $content;
     $model->title = $title;
     $model->useId = $useId;
     $model->keywords = $keywords;
     $model->pic = $pic;
     $model->content = $content;
     $model->addTime = date('Y-m-d H:i:s', time());
     $model->addUser = Yii::$app->session->get(Variable::$session_userId_str);
     if ($model->save()) {
         return true;
     }
     return false;
 }
 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]);
 }
 /**
  * Finds the Article model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Article the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Article::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 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]);
 }