12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- /**
- * Created by PhpStorm.
- * Author: 莫名疯
- * DateTime: 2017/3/8 10:09
- * Description:
- */
- 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 {
- /**
- * @api {get} /v1/carousels 列表
- * @apiVersion 1.0.0
- * @apiName index
- * @apiGroup Carousel
- *
- *
- */
- 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;
- }
- }
|