Skip to content

Commit a5a2ccd

Browse files
committed
profile 更新
1 parent 5a3bffd commit a5a2ccd

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

models/Profile.php

+37-11
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,25 @@
2020
* @property string $website
2121
* @property string $bio
2222
* @property string $timezone 时区
23-
* @property User $user
23+
*
24+
*
25+
* @property-read string $greenName 性别
26+
* @property-read User $user
2427
*/
2528
class Profile extends ActiveRecord
2629
{
2730
// 未选择
28-
const GENDER_UNCONFIRMED = 0;
31+
const GENDER_UNCONFIRMED = 0b0;
32+
2933
// 男
30-
const GENDER_MALE = 1;
34+
const GENDER_MALE = 0b1;
35+
3136
// 女
32-
const GENDER_FEMALE = 2;
37+
const GENDER_FEMALE = 0b10;
3338

39+
/**
40+
* @var string 性别字符串
41+
*/
3442
public $genderName;
3543

3644
/**
@@ -52,17 +60,26 @@ public static function find()
5260
public function rules()
5361
{
5462
return [
55-
['timezone', 'validateTimeZone'],
56-
['mobile', 'string', 'min' => 11, 'max' => 11],
5763
['gender', 'default', 'value' => self::GENDER_UNCONFIRMED],
5864
['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'],
6371
['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'],
6576
['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'],
6683
];
6784
}
6885

@@ -82,6 +99,15 @@ public function attributeLabels()
8299
'timezone' => Yii::t('user', 'Time zone'),
83100
'introduction' => Yii::t('user', 'Introduction'),
84101
'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'),
85111
];
86112
}
87113

models/User.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function rules()
225225
'mobilePattern' => ['mobile', 'match', 'pattern' => static::$mobileRegexp],
226226
'mobileLength' => ['mobile', 'string', 'max' => 11],
227227
'mobileUnique' => ['mobile', 'unique', 'message' => Yii::t('user', 'This mobile address has already been taken')],
228-
'mobileDefault' => ['email', 'default', 'value' => null, 'on' => ['register', 'create']],
228+
'mobileDefault' => ['mobile', 'default', 'value' => null, 'on' => ['register', 'create']],
229229

230230
// password rules
231231
'passwordRequired' => ['password', 'required', 'on' => ['register', 'mobile_register']],

0 commit comments

Comments
 (0)