/** * Updates an existing TravellerDescription model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $traveller_photo = TravellerPhoto::find()->where(['traveller_id' => $model->traveller_id])->one(); $traveller_help = TravellerHelp::find()->where(['traveller_id' => $model->traveller_id])->one(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (count($traveller_help) > 0) { return $this->redirect(['travellerhelp/update', 'id' => $traveller_help->id]); } else { return $this->redirect(['travellerhelp/create', 'traveller_id' => $model->traveller_id]); } } else { return $this->render('update', ['model' => $model, 'traveller_id' => $model->traveller_id, 'traveller_help' => $traveller_help, 'traveller_photo' => $traveller_photo]); } }
/** * Updates an existing Travellers model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $model->scenario = 'addressDetails'; if ($model->load(Yii::$app->request->post()) && $model->save()) { $traveller_photo = TravellerPhoto::find()->where(['traveller_id' => $model->id])->one(); if (count($traveller_photo) > 0) { return $this->redirect(['travellerphoto/update', 'id' => $traveller_photo->id]); } else { return $this->redirect(['travellerphoto/create', 'traveller_id' => $model->id]); } } else { return $this->render('update', ['model' => $model]); } }
/** * Finds the TravellerPhoto model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TravellerPhoto the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TravellerPhoto::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }