Ejemplo n.º 1
0
 public function actionInsert()
 {
     if (Yii::$app->request->post()) {
         $msg = "";
         $request = Yii::$app->request;
         $emailId = $request->post('emailid');
         $userId = $request->post('userid');
         $result = Relation::find()->where(['user_id' => $userId, 'email_id' => $emailId])->one();
         if ($result == null) {
             $model = new Relation();
             $model->user_id = $userId;
             $model->email_id = $emailId;
             $model->save();
             $msg = "成功分发";
         } else {
             $msg = "分发失败,可能已经分发过了";
         }
         echo $msg;
     }
 }
Ejemplo n.º 2
0
 /**
  * Remove friend.
  *
  * @param $id Int
  * @return bool
  * @throws NotFoundHttpException
  */
 public function rmFriend($id)
 {
     if ($following = self::findIdentity($id)) {
         return $relation = Relation::find()->where('follower_id = :user_id AND following_id = :friend_id')->orWhere('follower_id = :friend_id AND following_id = :user_id')->params([':friend_id' => $following->id, ':user_id' => $this->id])->one()->delete();
     } else {
         throw new NotFoundHttpException();
     }
 }