Blame view

frontend/controllers/CatalogController.php 843 Bytes
550eac02   Administrator   second
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
  <?php
  
  namespace frontend\controllers;
  
  use Yii;
  use yii\web\Controller;
  use common\models\Catalog;
  use yii\web\HttpException;
  
  class CatalogController extends Controller
  {
  
      public function actionIndex()
      {
              
              if(!$catalog = Catalog::find()->where(['translit'=>$_GET['translit']])->with('childs')->one())
                      throw new HttpException(404, 'Данной странице не существует!');
              
              return $this->render('index', [
                      'catalog'=>$catalog,
              ]);
      }
      
      public function actionAll()
      {
             
              $catalogs = Catalog::find()->where(['parent_id'=>0])->orderBy('sort ASC')->all();
              
              return $this->render('all', [
                      'catalogs'=>$catalogs,
              ]);
      }    
      
  }