コード例 #1
0
 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']);
     }
 }
コード例 #2
0
 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]);
 }