3 namespace app\controllers;
7 use app\models\TypesSearch;
8 use yii\web\Controller;
9 use yii\web\NotFoundHttpException;
10 use yii\filters\VerbFilter;
13 * TypesController implements the CRUD actions for Types model.
15 class TypesController extends Controller
20 public function behaviors()
24 'class' => VerbFilter::className(),
33 * Lists all Types models.
36 public function actionIndex()
38 $searchModel = new TypesSearch();
39 $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
41 return $this->render('index', [
42 'searchModel' => $searchModel,
43 'dataProvider' => $dataProvider,
48 * Displays a single Types model.
51 * @throws NotFoundHttpException if the model cannot be found
53 public function actionView($id)
55 return $this->render('view', [
56 'model' => $this->findModel($id),
61 * Creates a new Types model.
62 * If creation is successful, the browser will be redirected to the 'view' page.
65 public function actionCreate()
69 if ($model->load(Yii::$app->request->post()) && $model->save()) {
70 return $this->redirect(['index', 'id' => $model->id]);
73 return $this->render('create', [
79 * Updates an existing Types model.
80 * If update is successful, the browser will be redirected to the 'view' page.
83 * @throws NotFoundHttpException if the model cannot be found
85 public function actionUpdate($id)
87 $model = $this->findModel($id);
89 if ($model->load(Yii::$app->request->post()) && $model->save()) {
90 return $this->redirect(['index', 'id' => $model->id]);
93 return $this->render('update', [
99 * Deletes an existing Types model.
100 * If deletion is successful, the browser will be redirected to the 'index' page.
103 * @throws NotFoundHttpException if the model cannot be found
105 public function actionDelete($id)
107 $this->findModel($id)->delete();
109 return $this->redirect(['index']);
113 * Finds the Types model based on its primary key value.
114 * If the model is not found, a 404 HTTP exception will be thrown.
116 * @return Types the loaded model
117 * @throws NotFoundHttpException if the model cannot be found
119 protected function findModel($id)
121 if (($model = Types::findOne($id)) !== null) {
125 throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));