Beispiel #1
0
 public function api_carousel_items($slug_carousel)
 {
     $carousel = CarouselsModel::find()->where(['slug' => $slug_carousel])->one();
     if ($carousel) {
         if (!$this->_carousel_items) {
             $this->_carousel_items = [];
             foreach (ItemCarousel::find()->status(ItemCarousel::STATUS_ON)->where(['carousel_id' => $carousel->carousel_id])->orderBy(['order_num' => SORT_DESC])->all() as $item) {
                 $this->_carousel_items[] = $item;
             }
         }
         return $this->_carousel_items;
     }
 }
Beispiel #2
0
 public function actionDelete($id)
 {
     if ($model = ItemCarousel::findOne($id)) {
         $model->delete();
     } else {
         $this->error = Yii::t('easyii', 'Not found');
     }
     return $this->formatResponse(Yii::t('easyii/article', 'Article deleted'));
 }
 public function down()
 {
     $this->dropTable(Carousels::tableName());
     $this->dropTable(ItemCarousel::tableName());
 }
Beispiel #4
0
 public function getItems()
 {
     return $this->hasMany(ItemCarousel::className(), ['carousel_id' => 'carousel_id'])->orderBy(['order_num' => SORT_ASC]);
 }