Blame view

frontend/controllers/EventController.php 1.08 KB
84b2aead   Administrator   add active menu
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
  <?php

  

  namespace frontend\controllers;

  

  use Yii;

  use common\models\Event;

  use yii\web\Controller;

  use yii\web\NotFoundHttpException;

  use yii\data\ActiveDataProvider;

  

  

  

  class EventController extends Controller

  {

  

      public function actionIndex()

      {

  

          $dataProvider = new ActiveDataProvider([

              'query' => Event::find() ]);

  

          return $this->render('index', [

              'dataProvider' => $dataProvider,

          ]);

      }

  

  

  

      public function actionShow($alias)

      {

  

873e3d80   Administrator   14.09.16
32
33
34
35
          $model = $this->findModel($alias);

          $productProvider = new ActiveDataProvider([

              'query' => $model->getProducts(),

          ]);

84b2aead   Administrator   add active menu
36
          return $this->render('show', [

873e3d80   Administrator   14.09.16
37
38
              'productProvider' => $productProvider,

              'model' => $model,

84b2aead   Administrator   add active menu
39
40
41
42
43
44
45
46
47
48
49
50
51
52
          ]);

      }

  

  

      protected function findModel($alias)

      {

          if (($model = Event::findOne(["alias"=>$alias])) !== null) {

              return $model;

          } else {

              throw new NotFoundHttpException('The requested page does not exist.');

          }

      }

  

  

055ecc3b   Karnovsky A   Karnovsky 11052016
53
  }