/** * Updates an existing TravellersBestThing 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_id = $model->traveller_id; $TravellersLifeAgenda = TravellersLifeAgenda::find()->where(['traveller_id' => $traveller_id])->one(); $TravellersTrevell = TravellersCountries::find()->where(['traveller_id' => $traveller_id])->one(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (count($TravellersTrevell) > 0) { return $this->redirect(['travellerscountries/update', 'id' => $traveller_id]); } else { return $this->redirect(['travellerscountries/create', 'traveller_id' => $traveller_id]); } } else { return $this->render('create', ['model' => $model, 'traveller_id' => $traveller_id, 'TravellersLifeAgenda' => $TravellersLifeAgenda, 'TravellersTrevell' => $TravellersTrevell]); } }
/** * Finds the TravellersLifeAgenda model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TravellersLifeAgenda the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TravellersLifeAgenda::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }