public function actionDelete($id) { $model = new Route(); if ($model->delete($id)) { Yii::$app->session->setFlash('success', '删除成功'); $this->redirect(['index']); } else { Yii::$app->session->setFlash('fail', '删除失败'); $this->redirect(['index']); } }
public function actionUpdate($id) { $model = Route::find($id); if ($model->load(Yii::$app->request->post())) { $auth = Yii::$app->authManager; $newItem = $auth->createPermission('/' . trim($model->route, '/')); $newItem->description = $model->description; if ($auth->update($id, $newItem)) { Yii::$app->session->setFlash('success', '修改成功'); $this->redirect(['index']); } else { Yii::$app->session->setFlash('success', '修改失败'); $this->redirect(['update']); } } return $this->render('update', ['model' => $model]); }