/** * Updates an existing TravellersFavourites 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; $TravellersFood = TravellersFood::find()->where(['traveller_id' => $traveller_id])->one(); $TravellersLifeAgenda = TravellersLifeAgenda::find()->where(['traveller_id' => $traveller_id])->one(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (count($TravellersLifeAgenda) > 0) { return $this->redirect(['travellerslifeagenda/update', 'id' => $TravellersLifeAgenda->id]); } else { return $this->redirect(['travellerslifeagenda/create', 'traveller_id' => $traveller_id]); } } else { return $this->render('update', ['model' => $model, 'TravellersFood' => $TravellersFood, 'traveller_id' => $traveller_id, 'TravellersLifeAgenda' => $TravellersLifeAgenda]); } }
/** * Updates an existing TravellersLanguages 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 TravellersLanguages(); $model->mother_language = Yii::$app->commoncomponent->getLanguagesArray($traveller->motherLanguages); $model->fluent_language = Yii::$app->commoncomponent->getLanguagesArray($traveller->fluentLanguages); $model->learning_language = Yii::$app->commoncomponent->getLanguagesArray($traveller->learningLanguages); $Languages = Yii::$app->commoncomponent->getAllLanguagesArray(); $travellerprofile = TravellersProfile::find()->where(['traveller_id' => $id])->one(); $travellerfood = TravellersFood::find()->where(['traveller_id' => $id])->one(); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->commoncomponent->deleteTravellerLanguages($id); Yii::$app->commoncomponent->saveTravellerLanguages($model->mother_language, $id, 'mother_language'); Yii::$app->commoncomponent->saveTravellerLanguages($model->fluent_language, $id, 'fluent'); Yii::$app->commoncomponent->saveTravellerLanguages($model->learning_language, $id, 'learning'); if (count($travellerfood) > 0) { return $this->redirect(['travellersfood/update', 'id' => $travellerfood->id]); } else { return $this->redirect(['travellersfood/create', 'traveller_id' => $traveller_id]); } } else { return $this->render('update', ['model' => $model, 'traveller_id' => $id, 'travellerprofile' => $travellerprofile, 'Languages' => $Languages, 'travellerfood' => $travellerfood]); } }
/** * Lists all TravellersFood models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => TravellersFood::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }