| @@ 74-85 (lines=12) @@ | ||
| 71 | * If creation is successful, the browser will be redirected to the 'view' page. |
|
| 72 | * @return mixed |
|
| 73 | */ |
|
| 74 | public function actionCreate() |
|
| 75 | { |
|
| 76 | $model = new Admin(); |
|
| 77 | ||
| 78 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
|
| 79 | return $this->redirect(['view', 'id' => $model->id]); |
|
| 80 | } else { |
|
| 81 | return $this->render('create', [ |
|
| 82 | 'model' => $model, |
|
| 83 | ]); |
|
| 84 | } |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * Updates an existing Admin model. |
|
| @@ 93-104 (lines=12) @@ | ||
| 90 | * @param integer $id |
|
| 91 | * @return mixed |
|
| 92 | */ |
|
| 93 | public function actionUpdate($id) |
|
| 94 | { |
|
| 95 | $model = $this->findModel($id); |
|
| 96 | ||
| 97 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
|
| 98 | return $this->redirect(['view', 'id' => $model->id]); |
|
| 99 | } else { |
|
| 100 | return $this->render('update', [ |
|
| 101 | 'model' => $model, |
|
| 102 | ]); |
|
| 103 | } |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Deletes an existing Admin model. |
|
| @@ 52-63 (lines=12) @@ | ||
| 49 | * 修改密码 |
|
| 50 | * @return string|yii\web\Response |
|
| 51 | */ |
|
| 52 | public function actionChangePassword() |
|
| 53 | { |
|
| 54 | $model = new ChangePasswordForm(); |
|
| 55 | if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { |
|
| 56 | Yii::$app->session->setFlash('success', '修改成功'); |
|
| 57 | return $this->redirect(['change-password']); |
|
| 58 | } else { |
|
| 59 | return $this->render('change-password', [ |
|
| 60 | 'model' => $model |
|
| 61 | ]); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * 设置个人信息 |
|