commit | author | age
|
90c639
|
1 |
<?php |
Z |
2 |
|
|
3 |
namespace app\models; |
|
4 |
|
|
5 |
use Yii; |
|
6 |
|
|
7 |
/** |
|
8 |
* This is the model class for table "{{%ecard}}". |
|
9 |
* |
|
10 |
* @property int $id |
|
11 |
* @property int $mall_id |
|
12 |
* @property string $name 卡密名称 |
|
13 |
* @property string $content 使用说明 |
|
14 |
* @property int $is_delete |
|
15 |
* @property string $created_at |
|
16 |
* @property string $updated_at |
|
17 |
* @property string $deleted_at |
|
18 |
* @property string $list 卡密字段 |
|
19 |
* @property int $sales 已售 |
|
20 |
* @property int $stock 库存 |
|
21 |
* @property int $is_unique 是否去重 0--否 1--是 |
|
22 |
* @property int $pre_stock 占用的库存 |
|
23 |
* @property int $total_stock 总库存 |
|
24 |
* @property EcardOptions[] $ecardOptions |
|
25 |
* @property GoodsWarehouse[] $goodsWarehouse |
|
26 |
*/ |
|
27 |
class Ecard extends \app\models\ModelActiveRecord |
|
28 |
{ |
|
29 |
/** |
|
30 |
* {@inheritdoc} |
|
31 |
*/ |
|
32 |
public static function tableName() |
|
33 |
{ |
|
34 |
return '{{%ecard}}'; |
|
35 |
} |
|
36 |
|
|
37 |
/** |
|
38 |
* {@inheritdoc} |
|
39 |
*/ |
|
40 |
public function rules() |
|
41 |
{ |
|
42 |
return [ |
|
43 |
[['mall_id', 'created_at', 'updated_at', 'deleted_at', 'list'], 'required'], |
|
44 |
[['mall_id', 'is_delete', 'sales', 'stock', 'is_unique', 'pre_stock', 'total_stock'], 'integer'], |
|
45 |
[['content', 'list'], 'string'], |
|
46 |
[['created_at', 'updated_at', 'deleted_at'], 'safe'], |
|
47 |
[['name'], 'string', 'max' => 255], |
|
48 |
]; |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* {@inheritdoc} |
|
53 |
*/ |
|
54 |
public function attributeLabels() |
|
55 |
{ |
|
56 |
return [ |
|
57 |
'id' => 'ID', |
|
58 |
'mall_id' => 'Mall ID', |
|
59 |
'name' => '卡密名称', |
|
60 |
'content' => '使用说明', |
|
61 |
'is_delete' => 'Is Delete', |
|
62 |
'created_at' => 'Created At', |
|
63 |
'updated_at' => 'Updated At', |
|
64 |
'deleted_at' => 'Deleted At', |
|
65 |
'list' => '卡密字段', |
|
66 |
'sales' => '已售', |
|
67 |
'stock' => '库存', |
|
68 |
'is_unique' => '是否去重 0--否 1--是', |
|
69 |
'pre_stock' => '占用的库存', |
|
70 |
'total_stock' => '总库存', |
|
71 |
]; |
|
72 |
} |
|
73 |
|
|
74 |
public function getEcardOptions() |
|
75 |
{ |
|
76 |
return $this->hasMany(EcardOptions::className(), ['ecard_id' => 'id']); |
|
77 |
} |
|
78 |
|
|
79 |
public function getGoodsWarehouse() |
|
80 |
{ |
|
81 |
return $this->hasMany(GoodsWarehouse::className(), ['ecard_id' => 'id'])->andWhere(['is_delete' => 0]); |
|
82 |
} |
|
83 |
} |