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 \yii\db\ActiveQuery */ public function getItems() { return $this->hasMany(Item::className(), ['note_id' => 'id']); }
public function getItemsWithOrderBy($priceField = 'price_shipping_sum', $order = SORT_DESC) { return $this->hasMany(Item::className(), ['id' => 'itemId'])->viaTable('links', ['hashId' => 'id'])->orderBy([$priceField => $order]); }