Ejemplo n.º 1
0
 public function actionCancelMsg()
 {
     $data = Yii::$app->request->post();
     $phone = User::findOne(['phone' => $data['phone']]);
     $info = CollectInteract::findOne(['userid' => $phone['id'], 'msg' => $data['msg']]);
     if ($info) {
         $info->delete();
         echo json_encode(array('flag' => 1, 'msg' => 'Cancel collect success!'));
     } else {
         echo json_encode(array('flag' => 0, 'msg' => 'Cancel collect fail!'));
     }
 }
 /**
  * Finds the CollectInteract model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CollectInteract the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CollectInteract::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }