コード例 #1
0
 /**
  * Updates an existing HostsFoods 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);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $newmodel = HostsFoodDetails::find()->where(['host_id' => $model->host_id])->one();
         if (count($newmodel) != 1) {
             return $this->redirect(['hostsfooddetails/create', 'host_id' => $model->host_id]);
         } else {
             return $this->redirect(['hostsfooddetails/update', 'id' => $newmodel->id]);
         }
     } else {
         return $this->render('update', ['model' => $model, 'host_id' => $model->host_id]);
     }
 }
コード例 #2
0
 /**
  * Lists all HostsFoodDetails models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => HostsFoodDetails::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }