public function actionCreateoffer($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { $newmodel = AboutHost::find()->where(['host_id' => $model->host_id])->one(); if (count($newmodel) != 1) { return $this->redirect(['abouthost/create', 'host_id' => $model->host_id]); } else { return $this->redirect(['abouthost/update', 'id' => $newmodel->id]); } } else { return $this->render('createoffer', ['model' => $model]); } }
/** * Finds the AboutHost model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return AboutHost the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = AboutHost::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }