Blame view

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