<?php
namespace common\components;

use yii\base\Behavior;
use common\models\Account;
use common\models\Product;

class ProductAwareBehavior extends Behavior{
	
	/** @var $product common\models\Product*/
	public function getProductName(){
		$result = "";
		$product = $this->owner->product;
		if (isset($product)){
			$result  = $product->name;
		}
		return $result;
	}

	
	public function getProduct(){
		return $this->owner->hasOne( Product::className(), ["id_product" =>"id_product" ] ) ;
	}
	
}