forked from sangkil/sangkilbiz3
/
Product.php
147 lines (132 loc) · 3.31 KB
/
Product.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
namespace biz\master\models;
use Yii;
/**
* This is the model class for table "product".
*
* @property integer $id_product
* @property string $cd_product
* @property string $nm_product
* @property integer $id_category
* @property integer $id_group
* @property string $create_at
* @property integer $create_by
* @property string $update_at
* @property integer $update_by
*
* @property ProductStock[] $productStocks
* @property ProductGroup $idGroup
* @property Category $idCategory
* @property Price[] $price
* @property ProductUom[] $productUoms
* @property Cogs $cogs
* @property ProductChild[] $productChildren
*/
class Product extends \yii\db\ActiveRecord
{
const STATUS_ACTIVE = 1;
const STATUS_INACTIVE = 2;
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%product}}';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['cd_product', 'nm_product', 'id_category', 'id_group','status'], 'required'],
[['id_category', 'id_group','status'], 'integer'],
[['cd_product'], 'string', 'max' => 13],
[['nm_product'], 'string', 'max' => 64],
[['cd_product'], 'unique']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_product' => 'Id Product',
'cd_product' => 'Cd Product',
'nm_product' => 'Nm Product',
'id_category' => 'Id Category',
'id_group' => 'Id Group',
'create_at' => 'Create At',
'create_by' => 'Create By',
'update_at' => 'Update At',
'update_by' => 'Update By',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProductStocks()
{
return $this->hasMany(ProductStock::className(), ['id_product' => 'id_product']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getPrice()
{
return $this->hasMany(Price::className(), ['id_product' => 'id_product']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProductUoms()
{
return $this->hasMany(ProductUom::className(), ['id_product' => 'id_product']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getBarcodes()
{
return $this->hasMany(ProductChild::className(), ['id_product' => 'id_product']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCogs()
{
return $this->hasOne(Cogs::className(), ['id_product' => 'id_product']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getIdCategory()
{
return $this->hasOne(Category::className(), ['id_category' => 'id_category']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getIdGroup()
{
return $this->hasOne(ProductGroup::className(), ['id_group' => 'id_group']);
}
public function getCogsValue()
{
if ($this->cogs) {
return $this->cogs->cogs;
}
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'BizTimestampBehavior',
'BizBlameableBehavior',
'BizStatusConverter',
];
}
}