50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
use app\models\Expositions;
|
|
use app\models\Positions;
|
|
use app\models\register\Collections;
|
|
use app\services\JR;
|
|
|
|
$lg = Yii::$app->language;
|
|
$sliderPositions = Positions::findOne(70);
|
|
$whatsNewPositions = Positions::find()->where(['id' => 1])->one();
|
|
$collections = Collections::find()->where(['is_selected' => 1, 'deleted' => 0])->all();
|
|
$expositions = Expositions::find()->where(['is_active' => 1, 'is_selected' => 1])->all();
|
|
|
|
$pos = function ($incomingPosition) use ($lg) {
|
|
$items = [];
|
|
/** @var Positions $position */
|
|
foreach ($incomingPosition->positions as $position) {
|
|
if ($position->articleModel) {
|
|
$items[] = (object)[
|
|
'id' => $position->articleModel->id,
|
|
'img' => $position->articleModel->article->image('16:11'),
|
|
'title' => $position->articleModel->{'title' . ($lg == 'en' ? '_en' : '')},
|
|
'type' => $position->articleModel->art_table
|
|
];
|
|
}
|
|
}
|
|
return $items;
|
|
};
|
|
|
|
$coll = function ($inc) use ($lg) {
|
|
$items = [];
|
|
/** @var Collections | Expositions $item */
|
|
foreach ($inc as $item) {
|
|
$items[] = (object)[
|
|
'id' => $item->id,
|
|
'img' => $item->getImg(),
|
|
'title' => $item->title()
|
|
];
|
|
}
|
|
return $items;
|
|
};
|
|
|
|
|
|
JR::message(JR::done, ['obj' => [
|
|
'slides' => $pos($sliderPositions),
|
|
'whats_new' => $pos($whatsNewPositions),
|
|
'collections' => $coll($collections),
|
|
'expositions' => $coll($expositions)
|
|
]]);
|