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; } }