예제 #1
0
 public function actionCancelZan()
 {
     $data = Yii::$app->request->post();
     $user = new User();
     $phone = $user->find()->select('id')->where(['phone' => $data['phone']])->one();
     $info = Zan::findOne(['myid' => $phone['id'], 'msgid' => $data['msgid']]);
     if ($info) {
         $info->delete();
         echo json_encode(array('flag' => 1, 'msg' => 'Cancel success!'));
     } else {
         echo json_encode(array('flag' => 0, 'msg' => 'Cancel failed!'));
     }
 }
예제 #2
0
 /**
  * Finds the Zan model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Zan the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Zan::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }