1da76554
Administrator
big commti
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<?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
{
|
076b9c96
Administrator
big commti
|
16
|
public function actionMain()
|
1da76554
Administrator
big commti
|
17
18
19
|
{
$dataProvider = new ActiveDataProvider([
|
37415bee
Administrator
big commti
|
20
|
'query' => Event::find()->where(['is_event'=>true]) ]);
|
1da76554
Administrator
big commti
|
21
22
23
24
25
26
27
28
29
30
31
32
33
|
return $this->render('index', [
'dataProvider' => $dataProvider,
]);
}
public function actionShow($alias)
{
$model = $this->findModel($alias);
$productProvider = new ActiveDataProvider([
|
db2894a2
Administrator
big commti
|
34
35
36
37
38
39
40
41
|
'query' => $model->getProducts()->with([
'images',
'events',
'variant',
'variant.image',
'comments',
'averageRating',
]),
|
1da76554
Administrator
big commti
|
42
|
]);
|
db2894a2
Administrator
big commti
|
43
|
|
1da76554
Administrator
big commti
|
44
45
46
47
48
49
|
return $this->render('show', [
'productProvider' => $productProvider,
'model' => $model,
]);
}
|
9ec47b63
Administrator
big commti
|
50
51
52
|
public function actionSale($percent)
{
|
950470c1
Administrator
big commti
|
53
|
$model = Event::find()->where(['percent'=>$percent, 'sale'=>true])->one();
|
db2894a2
Administrator
big commti
|
54
|
|
9ec47b63
Administrator
big commti
|
55
|
$productProvider = new ActiveDataProvider([
|
db2894a2
Administrator
big commti
|
56
57
58
59
60
61
62
63
|
'query' => $model->getProducts()->with([
'images',
'events',
'variant',
'variant.image',
'comments',
'averageRating',
]),
|
9ec47b63
Administrator
big commti
|
64
|
]);
|
db2894a2
Administrator
big commti
|
65
|
|
9ec47b63
Administrator
big commti
|
66
67
68
69
70
|
return $this->render('show', [
'productProvider' => $productProvider,
'model' => $model,
]);
}
|
1da76554
Administrator
big commti
|
71
72
73
|
protected function findModel($alias)
{
|
950470c1
Administrator
big commti
|
74
|
if (($model = Event::findOne(["alias"=>$alias,'is_event' => true])) !== null) {
|
1da76554
Administrator
big commti
|
75
76
77
78
79
80
81
82
|
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
|