Commit 2689758be34eefa73995ec3c514cc15a5cfd318a
1 parent
acd74908
full commit
Showing
1 changed file
with
14 additions
and
9 deletions
Show diff stats
models/Customer.php
| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | * @property integer $id |
| 13 | 13 | * @property string $username |
| 14 | 14 | * @property string $password_hash |
| 15 | - * @property string $name | |
| 16 | 15 | * @property string $surname |
| 17 | 16 | * @property string $phone |
| 18 | 17 | * @property string $gender |
| ... | ... | @@ -58,9 +57,6 @@ |
| 58 | 57 | ], |
| 59 | 58 | [ |
| 60 | 59 | [ |
| 61 | - 'birth_day', | |
| 62 | - 'birth_month', | |
| 63 | - 'birth_year', | |
| 64 | 60 | 'group_id', |
| 65 | 61 | 'status', |
| 66 | 62 | 'created_at', |
| ... | ... | @@ -79,8 +75,8 @@ |
| 79 | 75 | ], |
| 80 | 76 | [ |
| 81 | 77 | [ |
| 78 | + 'birthday', | |
| 82 | 79 | 'username', |
| 83 | - 'name', | |
| 84 | 80 | 'surname', |
| 85 | 81 | 'phone', |
| 86 | 82 | 'email', |
| ... | ... | @@ -108,13 +104,10 @@ |
| 108 | 104 | return [ |
| 109 | 105 | 'id' => Yii::t('app', 'id'), |
| 110 | 106 | 'username' => Yii::t('app', 'username'), |
| 111 | - 'name' => Yii::t('app', 'cname'), | |
| 112 | 107 | 'surname' => Yii::t('app', 'surname'), |
| 113 | 108 | 'phone' => Yii::t('app', 'phone'), |
| 114 | 109 | 'gender' => Yii::t('app', 'gender'), |
| 115 | - 'birth_day' => Yii::t('app', 'birth_day'), | |
| 116 | - 'birth_month' => Yii::t('app', 'birth_month'), | |
| 117 | - 'birth_year' => Yii::t('app', 'birth_year'), | |
| 110 | + 'birthday' => Yii::t('app', 'birthday'), | |
| 118 | 111 | 'body' => Yii::t('app', 'body'), |
| 119 | 112 | 'group_id' => Yii::t('app', 'group_id'), |
| 120 | 113 | 'email' => Yii::t('app', 'email'), |
| ... | ... | @@ -152,6 +145,18 @@ |
| 152 | 145 | { |
| 153 | 146 | return $this->username . ' ' . $this->surname; |
| 154 | 147 | } |
| 148 | + | |
| 149 | + | |
| 150 | + public function beforeSave($insert) | |
| 151 | + { | |
| 152 | + if (parent::beforeSave($insert)) { | |
| 153 | + | |
| 154 | + $this->birthday = !empty($this->birthday) ? (string)strtotime($this->birthday) : ''; | |
| 155 | + return true; | |
| 156 | + } | |
| 157 | + return false; | |
| 158 | + | |
| 159 | + } | |
| 155 | 160 | |
| 156 | 161 | public function getPassword() |
| 157 | 162 | { | ... | ... |