Blame view

frontend/controllers/EventsController.php 941 Bytes
c7f222e2   Artem   first
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  <?php
  namespace frontend\controllers;
  use Yii;
  use yii\web\Controller;
  use common\models\Events;
  use common\models\EventsSearch;
  use yii\data\ActiveDataProvider;
  use yii\web\NotFoundHttpException;
  
  class EventsController extends Controller{
      public function actionIndex()
      {
          $query = Events::find();
  
          $dataProvider = new ActiveDataProvider([
              'query' => $query
  
          ]);
          return $this->render('index', [
  
              'dataProvider' => $dataProvider,
          ]);
      }
  
      public function actionView($translit)
      {
          return $this->render('view', [
              'model' => $this->findModel($translit),
          ]);
  
  
      }
      protected function findModel($translit)
      {
          if (($model = Events::findOne(["translit"=>$translit])) !== null) {
              return $model;
          } else {
              throw new NotFoundHttpException('The requested page does not exist.');
          }
      }
  }