Пример #1
0
 /**
  * Creates a new Zans model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Zans();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #2
0
 public function actionZan()
 {
     $data = Yii::$app->request->post();
     $user = new Users();
     $phone = $user->find()->select('id')->where(['phone' => $data['phone']])->one();
     $info = Zans::findOne(['userid' => $phone['id'], 'messageid' => $data['messageid']]);
     if ($info) {
         echo json_encode(array('flag' => 0, 'msg' => 'Already zan!'));
     } else {
         $model = new Zans();
         $model->userid = $phone['id'];
         $model->messageid = $data['messageid'];
         $model->created_at = time();
         $model->save();
         // 			$to=Message::findOne(['id'=>$data['msgid']]);
         // 			$model2=new Notify();
         // 			$model2->from=$phone['id'];
         // 			$model2->to=$to['userid'];
         // 			$model2->kind='点赞';
         // 			$model2->created_at=time();
         // 			$model2->msg_id=$data['msgid'];
         // 			$model2->save();
         return array('flag' => 1, 'msg' => 'Zan success!');
     }
 }