Beispiel #1
0
 /**
  * 获取指定用户的赞记录
  * @param null|int $authorId
  * @return mixed
  */
 public function getLike($authorId = null)
 {
     return $this->hasOne(Like::className(), ['target_id' => 'id'])->andWhere(['target_type' => self::TYPE, 'author_id' => $authorId ?: Yii::$app->getUser()->getId()]);
 }
Beispiel #2
0
 /**
  * 获取赞记录
  * @return mixed
  */
 public function getLike()
 {
     return $this->hasOne(Like::className(), ['target_id' => 'id'])->andWhere(['uid' => Yii::$app->user->getId(), 'target_type' => static::TYPE, 'type' => 'like']);
 }
Beispiel #3
0
 /**
  * 获取用户喜欢列表
  * @return static
  */
 public function getLikes()
 {
     return $this->hasMany(Like::className(), ['author_id' => 'id'])->inverseOf('author');
 }