public function afterDelete() { foreach (SliderItem::find()->where('slider_id = :id', [':id' => $this->id])->all() as $item) { $item->delete(); } parent::afterDelete(); // TODO: Change the autogenerated stub }
public function run() { $options = ['slidesToShow' => $this->slidesToShow, 'dots' => $this->dots, 'lazyLoad' => 'progressive', 'infinite' => $this->infinite, 'centerMode' => $this->centerMode, 'variableWidth' => $this->variableWidth, 'prevArrow' => '<i class="slick-prev material-icons">keyboard_arrow_left</i>', 'nextArrow' => '<i class="slick-next material-icons">keyboard_arrow_right</i>', 'customPaging' => 'function(slider, i) {return $("<i class=material-icons>radio_button_unchecked</i>")}']; $value_arr = []; $replace_keys = []; foreach ($options as $key => &$value) { if (strpos($value, 'function(') === 0) { $value_arr[] = $value; $value = '%' . $key . '%'; $replace_keys[] = '"' . $value . '"'; } } $options = json_encode($options); $options = str_replace($replace_keys, $value_arr, $options); $this->items = SliderItem::findAll(['slider_id' => $this->id]); if ($this->items) { $view = $this->view; $view->registerJs("jQuery('.widget-slider-{$this->id}').removeClass('hidden').slick({$options});", $view::POS_LOAD); return implode("\n", [Html::beginTag('div', $this->options), $this->renderItems(), Html::endTag('div')]) . "\n"; } }
public function getItem() { return $this->hasOne(SliderItem::className(), ['fid' => 'fid']); }
public function actionSliderItemDelete($id) { return SliderItem::findOne($id)->delete(); }