/** * Creates a new UserDlt model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new UserTourcompany(); $modelUser = new User(); $modelUser->scenario = 'create'; if ($modelUser->load(Yii::$app->request->post()) && $model->load(Yii::$app->request->post()) && Model::validateMultiple([$modelUser, $model])) { $modelUser->setPassword($modelUser->password); $modelUser->generateAuthKey(); $modelUser->user_type = 5; if ($modelUser->save()) { $model->user_id = $modelUser->id; $model->save(); } return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model, 'modelUser' => $modelUser]); } }