1 | <?php |
||
33 | class Admin extends ActiveRecord implements IdentityInterface |
||
34 | { |
||
35 | const STATUS_INACTIVE = 0; |
||
36 | const STATUS_ACTIVE = 10; |
||
37 | |||
38 | public $imageFile; |
||
39 | |||
40 | public $isAdmin = true; |
||
41 | |||
42 | /** |
||
43 | * @var string|null the current password value from form input |
||
44 | */ |
||
45 | protected $_password; |
||
46 | |||
47 | /** |
||
48 | * @inheritdoc |
||
49 | 32 | */ |
|
50 | public static function tableName() |
||
54 | |||
55 | /** |
||
56 | * @return AdminQuery custom query class with user scopes |
||
57 | 30 | */ |
|
58 | public static function find() |
||
62 | |||
63 | /** |
||
64 | * @inheritdoc |
||
65 | 14 | */ |
|
66 | public function scenarios() |
||
72 | |||
73 | /** |
||
74 | * @inheritdoc |
||
75 | 14 | */ |
|
76 | public function rules() |
||
106 | |||
107 | /** |
||
108 | * @inheritdoc |
||
109 | 2 | */ |
|
110 | public function attributeLabels() |
||
126 | |||
127 | /** |
||
128 | * @inheritdoc |
||
129 | 33 | */ |
|
130 | public function behaviors() |
||
138 | |||
139 | /** |
||
140 | * @inheritdoc |
||
141 | 13 | */ |
|
142 | public function beforeSave($insert) |
||
156 | |||
157 | /** |
||
158 | * @inheritdoc |
||
159 | 5 | */ |
|
160 | public static function findIdentity($id) |
||
164 | |||
165 | /** |
||
166 | * @inheritdoc |
||
167 | 1 | */ |
|
168 | public static function findIdentityByAccessToken($token, $type = null) |
||
172 | |||
173 | /** |
||
174 | * @inheritdoc |
||
175 | 18 | */ |
|
176 | public function getId() |
||
180 | |||
181 | /** |
||
182 | * @inheritdoc |
||
183 | 1 | */ |
|
184 | public function getAuthKey() |
||
188 | |||
189 | /** |
||
190 | * @inheritdoc |
||
191 | 1 | */ |
|
192 | public function validateAuthKey($authKey) |
||
196 | |||
197 | /** |
||
198 | * Validates password |
||
199 | * |
||
200 | * @param string $password password to validate |
||
201 | * @return boolean if password provided is valid for current user |
||
202 | 7 | */ |
|
203 | public function validatePassword($password) |
||
207 | |||
208 | /** |
||
209 | * Generates password hash from password and sets it to the model |
||
210 | * |
||
211 | * @param string $password |
||
212 | 6 | */ |
|
213 | public function setPassword($password) |
||
220 | |||
221 | /** |
||
222 | * @return string|null the current password value, if set from form. Null otherwise. |
||
223 | */ |
||
224 | public function getPassword() |
||
228 | |||
229 | /** |
||
230 | * Generates "remember me" authentication key |
||
231 | 1 | */ |
|
232 | public function generateAuthKey() |
||
236 | |||
237 | /** |
||
238 | * Generates new email confirmation token |
||
239 | * @param bool $save whether to save the record. Default is `false`. |
||
240 | * @return bool|null whether the save was successful or null if $save was false. |
||
241 | */ |
||
242 | public function generateEmailConfirmationToken($save = false) |
||
249 | |||
250 | /** |
||
251 | * Generates new password reset token |
||
252 | * @param bool $save whether to save the record. Default is `false`. |
||
253 | * @return bool|null whether the save was successful or null if $save was false. |
||
254 | 5 | */ |
|
255 | public function generatePasswordResetToken($save = false) |
||
262 | |||
263 | /** |
||
264 | * Resets to a new password and deletes the password reset token. |
||
265 | * @param string $password the new password for this user. |
||
266 | * @return bool whether the record was updated successfully |
||
267 | 5 | */ |
|
268 | public function resetPassword($password) |
||
274 | |||
275 | public static function getStatusList() |
||
282 | 2 | ||
283 | 2 | /** |
|
284 | 1 | * 上传头像 |
|
285 | * @return bool |
||
286 | 2 | */ |
|
287 | 2 | public function upload() |
|
303 | |||
304 | 1 | /** |
|
305 | * 获取头像地址 |
||
306 | * @return string |
||
307 | */ |
||
308 | public function getImageUrl() |
||
315 | } |
||
316 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: