20
20
* @property string $website
21
21
* @property string $bio
22
22
* @property string $timezone 时区
23
- * @property User $user
23
+ *
24
+ *
25
+ * @property-read string $greenName 性别
26
+ * @property-read User $user
24
27
*/
25
28
class Profile extends ActiveRecord
26
29
{
27
30
// 未选择
28
- const GENDER_UNCONFIRMED = 0 ;
31
+ const GENDER_UNCONFIRMED = 0b0 ;
32
+
29
33
// 男
30
- const GENDER_MALE = 1 ;
34
+ const GENDER_MALE = 0b1 ;
35
+
31
36
// 女
32
- const GENDER_FEMALE = 2 ;
37
+ const GENDER_FEMALE = 0b10 ;
33
38
39
+ /**
40
+ * @var string 性别字符串
41
+ */
34
42
public $ genderName ;
35
43
36
44
/**
@@ -52,17 +60,26 @@ public static function find()
52
60
public function rules ()
53
61
{
54
62
return [
55
- ['timezone ' , 'validateTimeZone ' ],
56
- ['mobile ' , 'string ' , 'min ' => 11 , 'max ' => 11 ],
57
63
['gender ' , 'default ' , 'value ' => self ::GENDER_UNCONFIRMED ],
58
64
['gender ' , 'in ' , 'range ' => [self ::GENDER_MALE , self ::GENDER_FEMALE , self ::GENDER_UNCONFIRMED ]],
59
- ['email ' , 'email ' ],
60
- ['website ' , 'url ' ],
61
- ['address ' , 'string ' ],
62
- ['introduction ' , 'string ' ],
65
+
66
+ ['mobile ' , 'match ' , 'pattern ' => User::$ mobileRegexp ],
67
+ ['mobile ' , 'string ' , 'min ' => 11 , 'max ' => 11 ],
68
+ ['email ' , 'email ' , 'checkDNS ' => true ],
69
+
70
+ ['email ' , 'trim ' ],
63
71
['bio ' , 'string ' ],
64
- [['email ' , 'timezone ' , 'country ' , 'location ' , 'website ' ], 'string ' , 'max ' => 255 ],
72
+ ['birthday ' , 'date ' , 'format ' => 'php:Y-m-d ' , 'min ' => '1900-01-01 ' , 'max ' => date ('Y-m-d ' )],
73
+ ['birthday ' , 'string ' , 'max ' => 15 ],
74
+ ['website ' , 'url ' ],
75
+ ['timezone ' , 'validateTimeZone ' ],
65
76
['qq ' , 'integer ' , 'min ' => 10001 , 'max ' => 9999999999 ],
77
+ [['weibo ' , 'wechat ' , 'facebook ' , 'twitter ' ,], 'string ' , 'max ' => 50 ],
78
+
79
+ [['email ' , 'country ' , 'province ' , 'city ' , 'location ' , 'address ' , 'website ' , 'introduction ' , 'company ' , 'company_job ' ,], 'string ' , 'max ' => 255 ],
80
+
81
+ //['current', 'integer'],
82
+ //['current', 'integer'],
66
83
];
67
84
}
68
85
@@ -82,6 +99,15 @@ public function attributeLabels()
82
99
'timezone ' => Yii::t ('user ' , 'Time zone ' ),
83
100
'introduction ' => Yii::t ('user ' , 'Introduction ' ),
84
101
'bio ' => Yii::t ('user ' , 'Bio ' ),
102
+ 'birthday ' => Yii::t ('user ' , 'Birthday ' ),
103
+ 'current ' => Yii::t ('user ' , 'Current ' ),
104
+ 'qq ' => Yii::t ('user ' , 'QQ ' ),
105
+ 'weibo ' => Yii::t ('user ' , 'Weibo ' ),
106
+ 'wechat ' => Yii::t ('user ' , 'WeChat ' ),
107
+ 'facebook ' => Yii::t ('user ' , 'Facebook ' ),
108
+ 'twitter ' => Yii::t ('user ' , 'Twitter ' ),
109
+ 'company ' => Yii::t ('user ' , 'Company ' ),
110
+ 'company_job ' => Yii::t ('user ' , 'Company Job ' ),
85
111
];
86
112
}
87
113
0 commit comments