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
 /**
  * Add new friend.
  *
  * @param $id Int
  * @return bool
  * @throws NotFoundHttpException
  */
 public function addFriend($id)
 {
     if ($following = self::findIdentity($id)) {
         $relation = new Relation();
         $relation->follower = $this;
         $relation->following = $following;
         return $relation->save();
     } else {
         throw new NotFoundHttpException();
     }
 }