/** * @return Address - associated with parent having type set to billing */ public function getBillingAddress() { return $this->hasOne(Address::className(), ['id' => 'addressId'])->viaTable(CoreTables::TABLE_MODEL_ADDRESS, ['parentId' => 'id'], function ($query, $type = Address::TYPE_BILLING) { $modelAddress = CoreTables::TABLE_MODEL_ADDRESS; $query->onCondition("{$modelAddress}.parentType=:ptype AND {$modelAddress}.type=:type", [':ptype' => $this->addressType, ':type' => $type]); }); }
/** * @return Address - associated address */ public function getAddress() { return $this->hasOne(Address::className(), ['id' => 'addressId']); }