forked from yiisoft/yii2-app-advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Customer.php
101 lines (92 loc) · 2.28 KB
/
Customer.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
<?php
namespace biz\models;
use Yii;
/**
* This is the model class for table "customer".
*
* @property integer $id_customer
* @property string $cd_cust
* @property string $nm_cust
* @property string $contact_name
* @property string $contact_number
* @property integer $status
* @property integer $update_by
* @property integer $create_by
* @property string $update_date
* @property string $create_date
* @property string $nmStatus
*
* @property CustomerDetail $customerDetail
* @property SalesHdr[] $salesHdrs
*/
class Customer extends \yii\db\ActiveRecord
{
const STATUS_INACTIVE = 0;
const STATUS_ACTIVE = 1;
const STATUS_BLOCKED = 2;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'customer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['cd_cust', 'nm_cust'], 'required'],
[['status'], 'integer'],
[['cd_cust'], 'string', 'max' => 13],
[['nm_cust', 'contact_name', 'contact_number'], 'string', 'max' => 64],
[['cd_cust'], 'unique']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_customer' => 'Id Customer',
'cd_cust' => 'Cd Cust',
'nm_cust' => 'Nm Cust',
'contact_name' => 'Contact Name',
'contact_number' => 'Contact Number',
'status' => 'Status',
'update_by' => 'Update By',
'create_by' => 'Create By',
'update_date' => 'Update Date',
'create_date' => 'Create Date',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCustomerDetail()
{
return $this->hasOne(CustomerDetail::className(), ['id_customer' => 'id_customer']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getSalesHdrs()
{
return $this->hasMany(SalesHdr::className(), ['id_customer' => 'id_customer']);
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'biz\behaviors\AutoTimestamp',
'biz\behaviors\AutoUser',
[
'class'=>'biz\behaviors\StatusBehavior'
]
];
}
}