public function actionIndex() { // $dataProvider = new ActiveDataProvider([ // 'query' => Travellers::find(), // ]); $user_id = $_GET['user_id']; $model = Travellers::find()->where(['user_id' => $user_id])->one(); if (count($model) == 0) { $model = new Travellers(); } $model->scenario = 'typeOfAccont'; if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->user_name != '') { return $this->redirect(['update', 'id' => $model->id]); } else { return $this->redirect(['create', 'id' => $model->id]); } } else { return $this->render('type', ['user_id' => $user_id, 'model' => $model]); } }