You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

114 lines
3.1 KiB

  1. <?php
  2. namespace backend\modules\motorcade\controllers;
  3. use Yii;
  4. use common\models\BaseRole;
  5. use common\models\searchRole;
  6. use yii\web\NotFoundHttpException;
  7. /**
  8. * RoleController implements the CRUD actions for BaseRole model.
  9. */
  10. class RoleController extends BaseController
  11. {
  12. public $layout = "@backend/modules/motorcade/views/layouts/iframe_new";
  13. /**
  14. * Lists all BaseRole models.
  15. * @return mixed
  16. */
  17. public function actionIndex()
  18. {
  19. $searchModel = new searchRole();
  20. $searchModel->ROLE_SYS = 1;
  21. $dataProvider = $searchModel->search(Yii::$app->request->queryParams + ['USER_ROLE'=> 1]);
  22. return $this->render('index', [
  23. 'searchModel' => $searchModel,
  24. 'dataProvider' => $dataProvider,
  25. ]);
  26. }
  27. /**
  28. * Displays a single BaseRole model.
  29. * @param integer $id
  30. * @return mixed
  31. */
  32. public function actionView($id)
  33. {
  34. return $this->render('view', [
  35. 'model' => $this->findModel($id),
  36. ]);
  37. }
  38. /**
  39. * Creates a new BaseRole model.
  40. * If creation is successful, the browser will be redirected to the 'view' page.
  41. * @return mixed
  42. */
  43. public function actionCreate($pid = '', $role = '')
  44. {
  45. $model = new BaseRole();
  46. $model->PARENT_MENU_ID = $pid;
  47. $model->ROLE_NAME = $role;
  48. $model->ROLE_SYS = BaseRole::ROLE_SYS_FO;
  49. if ($model->load(Yii::$app->request->post()) && $model->save()) {
  50. return $this->redirect(['view', 'id' => $model->ID]);
  51. } else {
  52. return $this->render('create', [
  53. 'model' => $model,
  54. ]);
  55. }
  56. }
  57. /**
  58. * Updates an existing BaseRole model.
  59. * If update is successful, the browser will be redirected to the 'view' page.
  60. * @param integer $id
  61. * @return mixed
  62. */
  63. public function actionUpdate($id)
  64. {
  65. $model = $this->findModel($id);
  66. $model->ROLE_SYS = BaseRole::ROLE_SYS_FO;
  67. if ($model->load(Yii::$app->request->post()) && $model->save()) {
  68. return $this->redirect(['view', 'id' => $model->ID]);
  69. } else {
  70. return $this->render('update', [
  71. 'model' => $model,
  72. ]);
  73. }
  74. }
  75. /**
  76. * Deletes an existing BaseRole model.
  77. * If deletion is successful, the browser will be redirected to the 'index' page.
  78. * @param integer $id
  79. * @return mixed
  80. */
  81. public function actionDelete($id)
  82. {
  83. $this->findModel($id)->delete();
  84. return $this->redirect(['index']);
  85. }
  86. /**
  87. * Finds the BaseRole model based on its primary key value.
  88. * If the model is not found, a 404 HTTP exception will be thrown.
  89. * @param integer $id
  90. * @return BaseRole the loaded model
  91. * @throws NotFoundHttpException if the model cannot be found
  92. */
  93. protected function findModel($id)
  94. {
  95. if (($model = BaseRole::findOne($id)) !== null) {
  96. return $model;
  97. } else {
  98. throw new NotFoundHttpException('The requested page does not exist.');
  99. }
  100. }
  101. }