/** * Creates a new HostsFoods model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new HostsFoods(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $newmodel = HostsFoodDetails::find()->where(['host_id' => $model->host_id])->one(); if (count($newmodel) != 1) { return $this->redirect(['hostsfooddetails/create', 'host_id' => $model->host_id]); } else { return $this->redirect(['hostsfooddetails/update', 'id' => $newmodel->id]); } } else { return $this->render('create', ['model' => $model, 'host_id' => $_GET['host_id']]); } }