<?php
namespace common\components;

use yii\base\Behavior;
use common\models\Sale;

class SaleAwareBehavior extends Behavior{
	
	
	public function getSaleName(){
		$result = "";
		$sale = $this->owner->sale;
		if (isset($sale)){
			$result  = $sale->name;
		}
		return $result;
	}

	
	public function getSale(){
		return $this->owner->hasOne( Sale::className(), ["id_sale" =>"id_sale" ] ) ;
	}
	
}