Advertisement
Guest User

Untitled

a guest
Oct 6th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. namespace common\behaviors;
  2.  
  3. use yii\behaviors\AttributeBehavior;
  4.  
  5. class IndividualServicePriceBehavior extends AttributeBehavior
  6. {
  7.  
  8. /**
  9. * @var \common\models\UniqueService
  10. */
  11. public $individualPrices;
  12. public $priceAttribute;
  13. public $idAttribute;
  14.  
  15. public function getValue($event)
  16. {
  17. foreach ($this->individualPrices as $individualPrice) {
  18. if($individualPrice['service_id'] == $this->owner->{$this->idAttribute}) {
  19. return $this->owner->{$this->priceAttribute} = $individualPrice['price'];
  20. }
  21. }
  22.  
  23. return $this->owner->{$this->priceAttribute};
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement