SiteController.php
1.46 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
<?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use app\models\Text;
use app\models\News;
use app\models\Catalog;
use app\models\Products;
class SiteController extends Controller
{
public function actionIndex()
{
$catalogs = Catalog::find()->where(['parent_id'=>'0'])->orderBy('sort ASC')->all();
$modelMenu = Text::find()->where(['translit'=>'home'])->one();
$news = News::find()->orderBy('id DESC')->limit(4)->all();
$products_new = Products::find()->where(['new'=>'1'])->orderBy('out_of_stock ASC, id DESC')->all();
$products_top = Products::find()->where(['top'=>'1'])->orderBy('out_of_stock ASC, id DESC')->all();
$products_akciya = Products::find()->where(['akciya'=>'1'])->orderBy('out_of_stock ASC, id DESC')->all();
return $this->render('index', [
'menu'=>$modelMenu,
'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(),
]);
}
}