add customer cart
This commit is contained in:
25
common/components/ProductAwareBehavior.php
Normal file
25
common/components/ProductAwareBehavior.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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" ] ) ;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user