1 | <?php |
||
27 | class BaseUserModel extends ActiveRecord implements IdentityInterface |
||
28 | { |
||
29 | /** |
||
30 | * Deleted Status |
||
31 | */ |
||
32 | const STATUS_DELETED = 0; |
||
33 | |||
34 | /** |
||
35 | * Active Status |
||
36 | */ |
||
37 | const STATUS_ACTIVE = 1; |
||
38 | |||
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | */ |
||
43 | public static function tableName() |
||
44 | { |
||
45 | return '{{%User}}'; |
||
46 | } |
||
47 | |||
48 | |||
49 | /** |
||
50 | * @inheritdoc |
||
51 | */ |
||
52 | public function behaviors() |
||
53 | { |
||
54 | return [ |
||
55 | 'timestamp' => [ |
||
56 | 'class' => 'yii\behaviors\TimestampBehavior', |
||
57 | 'createdAtAttribute' => 'createdAt', |
||
58 | 'updatedAtAttribute' => 'updatedAt' |
||
59 | ] |
||
60 | ]; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Returns the validation rules for attributes. |
||
65 | * |
||
66 | * Validation rules are used by [[validate()]] to check if attribute values are valid. |
||
67 | * Child classes may override this method to declare different validation rules. |
||
68 | */ |
||
69 | public function rules() |
||
77 | |||
78 | /** |
||
79 | * @return \yii\db\ActiveQuery |
||
80 | */ |
||
81 | public function getUserDetails() |
||
85 | |||
86 | /** |
||
87 | * @inheritdoc |
||
88 | */ |
||
89 | public static function findIdentity($id) |
||
93 | |||
94 | /** |
||
95 | * @inheritdoc |
||
96 | */ |
||
97 | public static function findIdentityByAccessToken($token, $type = null) |
||
101 | |||
102 | /** |
||
103 | * Finds user (with active status) by username |
||
104 | * |
||
105 | * @param string $username |
||
106 | * |
||
107 | * @return static|null |
||
108 | */ |
||
109 | public static function findByUsername($username) |
||
113 | |||
114 | /** |
||
115 | * Finds user by email |
||
116 | * |
||
117 | * @param $email |
||
118 | * @return null|static |
||
119 | */ |
||
120 | public static function findByEmail($email) |
||
124 | |||
125 | /** |
||
126 | * Finds user by password reset token |
||
127 | * |
||
128 | * @param string $token password reset token |
||
129 | * @return static|null |
||
130 | */ |
||
131 | public static function findByPasswordResetToken($token) |
||
142 | |||
143 | /** |
||
144 | * Finds out if password reset token is valid |
||
145 | * |
||
146 | * @param string $token password reset token |
||
147 | * @return boolean |
||
148 | */ |
||
149 | public static function isPasswordResetTokenValid($token) |
||
159 | |||
160 | /** |
||
161 | * @inheritdoc |
||
162 | */ |
||
163 | public function getId() |
||
167 | |||
168 | /** |
||
169 | * @inheritdoc |
||
170 | */ |
||
171 | public function getAuthKey() |
||
175 | |||
176 | /** |
||
177 | * @inheritdoc |
||
178 | */ |
||
179 | public function validateAuthKey($authKey) |
||
183 | |||
184 | /** |
||
185 | * Validates password |
||
186 | * |
||
187 | * @param string $password password to validate |
||
188 | * |
||
189 | * @return boolean if password provided is valid for current user |
||
190 | */ |
||
191 | public function validatePassword($password) |
||
195 | |||
196 | /** |
||
197 | * Generates password hash from password and sets it to the model |
||
198 | * |
||
199 | * @param string $password |
||
200 | */ |
||
201 | public function setPassword($password) |
||
205 | |||
206 | /** |
||
207 | * Generates "remember me" authentication key |
||
208 | */ |
||
209 | public function generateAuthKey() |
||
213 | |||
214 | /** |
||
215 | * Generates new password reset token |
||
216 | */ |
||
217 | public function generatePasswordResetToken() |
||
221 | |||
222 | /** |
||
223 | * Removes password reset token |
||
224 | */ |
||
225 | public function removePasswordResetToken() |
||
229 | |||
230 | /** |
||
231 | * Update last login |
||
232 | */ |
||
233 | public function updateLastLogin() |
||
237 | } |
||
238 |