/**
  * Creates a new Judge model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Judge();
     $data = Yii::$app->request->post();
     if ($data != false) {
         $userinfo = User::findOne(['phone' => $data['Judge']['userid']]);
         $model->userid = (string) $userinfo['id'];
         $model['message'] = $data['Judge']['message'];
         $model['created_at'] = time();
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionJudge()
 {
     $data = Yii::$app->request->post();
     $phone = User::findOne(['phone' => $data['phone']]);
     $model = new Judge();
     if ($data != false) {
         $model->userid = $phone->id;
         $model->message = $data['message'];
         $model->created_at = time();
         if ($model->save()) {
             echo json_encode(array('flag' => 1, 'msg' => 'Judge success!'));
         } else {
             echo json_encode(array('flag' => 0, 'msg' => 'Judge failed!'));
         }
     } else {
         echo json_encode(array('flag' => 0, 'msg' => 'Judge failed!'));
     }
 }