Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace common\behaviors;
- use yii\behaviors\AttributeBehavior;
- class IndividualServicePriceBehavior extends AttributeBehavior
- {
- /**
- * @var \common\models\UniqueService
- */
- public $individualPrices;
- public $priceAttribute;
- public $idAttribute;
- public function getValue($event)
- {
- foreach ($this->individualPrices as $individualPrice) {
- if($individualPrice['service_id'] == $this->owner->{$this->idAttribute}) {
- return $this->owner->{$this->priceAttribute} = $individualPrice['price'];
- }
- }
- return $this->owner->{$this->priceAttribute};
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement