fitness-web/common/components/CurrencyAwareBehavior.php
2015-10-21 17:57:16 +02:00

24 lines
441 B
PHP

<?php
namespace common\components;
use yii\base\Behavior;
use common\models\Currency;
class CurrencyAwareBehavior extends Behavior{
public function getCurrencyName(){
$result = "";
$currency = $this->owner->currency;
if (isset($currency)){
$result = $currency->name;
}
return $result;
}
public function getCurrency(){
return $this->owner->hasOne( Currency::className(), ["id_currency" =>"id_currency" ] ) ;
}
}