コード例 #1
0
ファイル: AddressTrait.php プロジェクト: cmsgears/module-core
 /**
  * @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]);
     });
 }
コード例 #2
0
ファイル: ModelAddress.php プロジェクト: cmsgears/module-core
 /**
  * @return Address - associated address
  */
 public function getAddress()
 {
     return $this->hasOne(Address::className(), ['id' => 'addressId']);
 }