12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace api\modules\v1\controllers;
- use api\common\controllers\Controller;
- use api\common\models\CarouselItem;
- use common\models\Carousel;
- use yii\data\ActiveDataProvider;
- class CarouselController extends Controller {
-
- public function actionIndex($key = 'index') {
- $data = new ActiveDataProvider([
- 'query' => CarouselItem::find()
- ->joinWith('carousel')
- ->where([
- '{{%carousel_item}}.status' => CarouselItem::STATUS_ACTIVE,
- '{{%carousel}}.status' => Carousel::STATUS_ACTIVE,
- '{{%carousel}}.key' => $key,
- ])
- ->limit(10),
- 'pagination' => false,
- 'sort' => [
- 'defaultOrder' => [
- 'sort' => SORT_ASC
- ]
- ],
- ]);
- return $data;
- }
- }
|