/**
  * Updates an existing TravellersLifeAgenda 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;
     $TravellersFavourites = TravellersFavourites::find()->where(['traveller_id' => $traveller_id])->one();
     $TravellersBestThing = TravellersBestThing::find()->where(['traveller_id' => $traveller_id])->one();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if (count($TravellersBestThing) > 0) {
             return $this->redirect(['travellersbestthing/update', 'id' => $TravellersBestThing->id]);
         } else {
             return $this->redirect(['travellersbestthing/create', 'traveller_id' => $traveller_id]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'traveller_id' => $traveller_id, 'TravellersFavourites' => $TravellersFavourites, 'TravellersBestThing' => $TravellersBestThing]);
     }
 }
 /**
  * Updates an existing TravellersCountries model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $traveller = \frontend\models\Travellers::findOne($id);
     $model = new TravellersCountries();
     $model->travelled_country = Yii::$app->commoncomponent->getCountriesArray($traveller->travelledCountries);
     $model->lived_country = Yii::$app->commoncomponent->getCountriesArray($traveller->livedCountries);
     $model->favourite_country = Yii::$app->commoncomponent->getCountriesArray($traveller->favouriteCountries);
     $Countries = Yii::$app->commoncomponent->getAllCountriesArray();
     $TravellersBestThing = TravellersBestThing::find()->where(['traveller_id' => $id])->one();
     if ($model->load(Yii::$app->request->post())) {
         Yii::$app->commoncomponent->deleteTravellerCountries($id);
         Yii::$app->commoncomponent->saveTravellerCountries($model->travelled_country, $id, 'travelled_country');
         Yii::$app->commoncomponent->saveTravellerCountries($model->lived_country, $id, 'lived_country');
         Yii::$app->commoncomponent->saveTravellerCountries($model->favourite_country, $id, 'favourite_country');
         return $this->redirect(['travellers/imagegallery', 'id' => $model->traveller_id]);
     } else {
         return $this->render('update', ['model' => $model, 'traveller_id' => $id, 'TravellersBestThing' => $TravellersBestThing, 'Countries' => $Countries]);
     }
 }
 /**
  * Finds the TravellersBestThing model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TravellersBestThing the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TravellersBestThing::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }