/** * Updates an existing TravellersFood 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(); $travellerlanguages = TravellersLanguages::find()->where(['traveller_id' => $traveller_id])->one(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (count($TravellersFavourites) > 0) { return $this->redirect(['travellersfavourites/update', 'id' => $TravellersFavourites->id]); } else { return $this->redirect(['travellersfavourites/create', 'traveller_id' => $traveller_id]); } } else { return $this->render('create', ['model' => $model, 'traveller_id' => $traveller_id, 'TravellersFavourites' => $TravellersFavourites, 'travellerlanguages' => $travellerlanguages]); } }
/** * Lists all TravellersFavourites models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => TravellersFavourites::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }