/**
  *  改变状态
  * @date: 2016-1-14 
  * @author: futao
  */
 public function changestateAction()
 {
     $req = $this->request;
     $state = $req->getQuery('state', null, '');
     $id = $req->getQuery('id', null, 0);
     $echo = function ($msg, $state = false) {
         echo '<script type="text/javascript">';
         echo 'parent.formResult("' . $msg . '", ' . ($state ? 1 : 0) . ')';
         echo '</script>';
     };
     if (in_array($state, [1, 0]) && $id > 0) {
         $hotModel = QuestionHotWords::findFirst($id);
         $hotModel->status = $state;
         if ($hotModel->save()) {
             echo "<script>window.parent.location.href='hotlist'</script>";
         } else {
             $echo("操作失败!");
         }
     } else {
         $echo("操作失败!");
     }
 }
Exemple #2
0
 public function run()
 {
     $this->setResult(QuestionHotWords::query()->columns(['title'])->where('status = 1')->execute()->toArray());
 }