commit | author | age
|
90c639
|
1 |
<?php |
Z |
2 |
|
|
3 |
namespace app\models; |
|
4 |
|
|
5 |
use yii\helpers\Html; |
|
6 |
|
|
7 |
/** |
|
8 |
* This is the model class for table "{{%address}}". |
|
9 |
* |
|
10 |
* @property int $id |
|
11 |
* @property int $user_id |
|
12 |
* @property string $name 收货人 |
|
13 |
* @property int $province_id |
|
14 |
* @property string $province 省份名称 |
|
15 |
* @property int $city_id |
|
16 |
* @property string $city 城市名称 |
|
17 |
* @property int $district_id |
|
18 |
* @property string $district 县区名称 |
|
19 |
* @property string $mobile 联系电话 |
|
20 |
* @property string $detail 详细地址 |
|
21 |
* @property int $is_default 是否默认 |
|
22 |
* @property int $is_delete 删除 |
|
23 |
* @property string $created_at |
|
24 |
* @property string $updated_at |
|
25 |
* @property string $deleted_at |
|
26 |
* @property string $latitude 经度 |
|
27 |
* @property string $longitude 纬度 |
|
28 |
* @property string $location 位置 |
|
29 |
* @property int $type 类型:0快递 1同城 |
|
30 |
*/ |
|
31 |
class Address extends ModelActiveRecord |
|
32 |
{ |
|
33 |
/** |
|
34 |
* {@inheritdoc} |
|
35 |
*/ |
|
36 |
public static function tableName() |
|
37 |
{ |
|
38 |
return '{{%address}}'; |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* {@inheritdoc} |
|
43 |
*/ |
|
44 |
public function rules() |
|
45 |
{ |
|
46 |
return [ |
|
47 |
[['user_id', 'name', 'mobile', 'detail', 'created_at', 'updated_at', 'deleted_at'], 'required'], |
|
48 |
[['user_id', 'province_id', 'city_id', 'district_id', 'is_default', 'is_delete', 'type'], 'integer'], |
|
49 |
[['created_at', 'updated_at', 'deleted_at'], 'safe'], |
|
50 |
[['name', 'province', 'city', 'district', 'mobile', 'latitude', 'longitude', 'location'], 'string', 'max' => 255], |
|
51 |
[['detail'], 'string', 'max' => 1000], |
|
52 |
]; |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* {@inheritdoc} |
|
57 |
*/ |
|
58 |
public function attributeLabels() |
|
59 |
{ |
|
60 |
return [ |
|
61 |
'id' => 'ID', |
|
62 |
'user_id' => 'User ID', |
|
63 |
'name' => '收货人', |
|
64 |
'province_id' => 'Province ID', |
|
65 |
'province' => '省份名称', |
|
66 |
'city_id' => 'City ID', |
|
67 |
'city' => '城市名称', |
|
68 |
'district_id' => 'District ID', |
|
69 |
'district' => '县区名称', |
|
70 |
'mobile' => '联系电话', |
|
71 |
'detail' => '详细地址', |
|
72 |
'is_default' => '是否默认', |
|
73 |
'is_delete' => '删除', |
|
74 |
'created_at' => 'Created At', |
|
75 |
'updated_at' => 'Updated At', |
|
76 |
'deleted_at' => 'Deleted At', |
|
77 |
'latitude' => '经度', |
|
78 |
'longitude' => '纬度', |
|
79 |
'location' => '位置', |
|
80 |
'type' => '类型:0快递 1同城' |
|
81 |
]; |
|
82 |
} |
|
83 |
|
|
84 |
public function beforeSave($insert) |
|
85 |
{ |
|
86 |
$this->name = Html::encode($this->name); |
|
87 |
$this->mobile = Html::encode($this->mobile); |
|
88 |
$this->detail = Html::encode($this->detail); |
|
89 |
return parent::beforeSave($insert); |
|
90 |
} |
|
91 |
} |