MenuToTheUserController.php 3.4 KB

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