/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @param null|string $slider
  *
  * @throws \yii\web\NotFoundHttpException
  * @return mixed
  */
 public function actionCreate($slider = null)
 {
     if (!$slider or !($sliderModel = Slider::findOne(['code' => $slider, 'active' => 1]))) {
         throw new NotFoundHttpException('Page not found');
     }
     $model = new SliderImage();
     $model->slider_id = $sliderModel->id;
     $model->save(false);
     $this->redirect(['update', 'id' => $model->id]);
 }
Esempio n. 2
0
 public function search($params)
 {
     $query = Slider::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->request->cookies->getValue('_grid_page_size', 20)], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['slider.id' => $this->id, 'slider.active' => $this->active, 'slider.width' => $this->width, 'slider.height' => $this->height, 'slider.created_at' => $this->created_at, 'slider.updated_at' => $this->updated_at, 'slider.has_link' => $this->has_link, 'slider.has_body' => $this->has_body]);
     $query->andFilterWhere(['like', 'slider.name', $this->name])->andFilterWhere(['like', 'slider.code', $this->code]);
     return $dataProvider;
 }
Esempio n. 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSlider()
 {
     return $this->hasOne(Slider::className(), ['id' => 'slider_id']);
 }