Example #1
0
 /**
  * 获取帖子标签(关联tag_item表)
  * @return mixed
  */
 public function getTags()
 {
     return $this->hasMany(Tag::className(), ['id' => 'tid'])->viaTable(TagItem::tableName(), ['target_id' => 'id'], function ($model) {
         $model->andWhere(['target_type' => self::TYPE]);
     });
 }
Example #2
0
 public function getTag()
 {
     return $this->hasOne(Tag::className(), ['tid' => 'id']);
 }