SiteController.php
1.72 KB
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
42
43
44
45
46
<?php
namespace frontend\controllers;
use Yii;
use yii\web\Controller;
use common\models\Page;
use common\models\News;
use common\models\Catalog;
use common\models\Products;
class SiteController extends Controller
{
public function actionIndex()
{
// $catalogs = Catalog::find()->where(['parent_id'=>'0'])->all();
$modelText = Page::find()->where(['translit'=>'home'])->one();
// $news = News::find()->orderBy('id DESC')->limit(4)->all();
// $products_new = Products::find()->where(['new'=>'1'])->orderBy('id DESC')->innerJoinWith(['cost'])->groupBy('id')->limit(4)->all();
// //print_r($products_new);
// $products_top = Products::find()->where(['top'=>'1'])->orderBy('id DESC')->innerJoinWith(['cost'])->groupBy('id')->limit(4)->all();
// //print_r($products_top);
// //$products_sale = Products::find()->where(['sale'=>'1'])->innerJoinWith(['cost'])->orderBy('id DESC')->limit(4)->all();
// $products_akciya = Products::find()->where(['akciya'=>'1'])->innerJoinWith(['cost'])->orderBy('id DESC')->limit(4)->all();
return $this->render('index', [
'text'=>$modelText,
// 'catalogs'=>$catalogs,
// 'news'=>$news,
// 'products_new'=>$products_new,
// 'products_top'=>$products_top,
// 'products_akciya'=>$products_akciya,
]);
}
public function actionError(){
return $this->render('error', [
'code'=>Yii::$app->errorHandler->exception->statusCode,
'message'=>Yii::$app->errorHandler->exception->getMessage(),
]);
}
}