|
- <?php
-
- namespace backend\modules\motorcade\controllers;
-
- use Yii;
- use common\models\BaseRole;
- use common\models\searchRole;
- use yii\web\NotFoundHttpException;
-
- /**
- * RoleController implements the CRUD actions for BaseRole model.
- */
- class RoleController extends BaseController
- {
- public $layout = "@backend/modules/motorcade/views/layouts/iframe_new";
-
- /**
- * Lists all BaseRole models.
- * @return mixed
- */
- public function actionIndex()
- {
- $searchModel = new searchRole();
- $searchModel->ROLE_SYS = 1;
- $dataProvider = $searchModel->search(Yii::$app->request->queryParams + ['USER_ROLE'=> 1]);
-
- return $this->render('index', [
- 'searchModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- ]);
- }
-
- /**
- * Displays a single BaseRole model.
- * @param integer $id
- * @return mixed
- */
- public function actionView($id)
- {
- return $this->render('view', [
- 'model' => $this->findModel($id),
- ]);
- }
-
- /**
- * Creates a new BaseRole model.
- * If creation is successful, the browser will be redirected to the 'view' page.
- * @return mixed
- */
- public function actionCreate($pid = '', $role = '')
- {
- $model = new BaseRole();
- $model->PARENT_MENU_ID = $pid;
- $model->ROLE_NAME = $role;
- $model->ROLE_SYS = BaseRole::ROLE_SYS_FO;
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->ID]);
- } else {
- return $this->render('create', [
- 'model' => $model,
- ]);
- }
- }
-
- /**
- * Updates an existing BaseRole model.
- * If update is successful, the browser will be redirected to the 'view' page.
- * @param integer $id
- * @return mixed
- */
- public function actionUpdate($id)
- {
- $model = $this->findModel($id);
-
- $model->ROLE_SYS = BaseRole::ROLE_SYS_FO;
- if ($model->load(Yii::$app->request->post()) && $model->save()) {
- return $this->redirect(['view', 'id' => $model->ID]);
- } else {
- return $this->render('update', [
- 'model' => $model,
- ]);
- }
- }
-
- /**
- * Deletes an existing BaseRole model.
- * If deletion is successful, the browser will be redirected to the 'index' page.
- * @param integer $id
- * @return mixed
- */
- public function actionDelete($id)
- {
- $this->findModel($id)->delete();
-
- return $this->redirect(['index']);
- }
-
- /**
- * Finds the BaseRole model based on its primary key value.
- * If the model is not found, a 404 HTTP exception will be thrown.
- * @param integer $id
- * @return BaseRole the loaded model
- * @throws NotFoundHttpException if the model cannot be found
- */
- protected function findModel($id)
- {
- if (($model = BaseRole::findOne($id)) !== null) {
- return $model;
- } else {
- throw new NotFoundHttpException('The requested page does not exist.');
- }
- }
- }
|