示例#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]);
     });
 }
 public function down()
 {
     $this->dropTable(Tag::tableName());
     $this->dropTable(TagItem::tableName());
 }