Exemple #1
0
 /**
  * 获取指定用户的收藏记录
  * @param null|int $authorId
  * @return mixed
  */
 public function getFavorite($authorId = null)
 {
     return $this->hasOne(Favorite::className(), ['target_id' => 'id'])->andWhere(['target_type' => self::TYPE, 'author_id' => $authorId ?: Yii::$app->getUser()->getId()]);
 }
Exemple #2
0
 /**
  * 获取收藏记录
  * @return mixed
  */
 public function getFavorite()
 {
     return $this->hasOne(Favorite::className(), ['target_id' => 'id'])->andWhere(['uid' => Yii::$app->user->getId(), 'target_type' => static::TYPE, 'type' => 'favorite']);
 }