public function getItems() { return $this->hasMany(Item::className(), ['id' => 'entity_1_id'])->viaTable(EntityLink::tableName(), ['entity_2_id' => 'id'], function ($query) { $query->onCondition(['entity_1' => Item::THIS_ENTITY, 'entity_2' => Video::THIS_ENTITY]); }); }
/** * @return Img[] */ public function getImgsSort() { $query = Img::find()->innerJoin(EntityLink::tableName(), Img::tableName() . '.id = `' . EntityLink::tableName() . '`.entity_2_id')->andWhere(['entity_1' => self::THIS_ENTITY, 'entity_2' => Img::THIS_ENTITY, 'entity_1_id' => $this->id])->orderBy(['sort' => SORT_ASC]); return $query->all(); }