/** * 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]); }