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