/** * Creates a new Personal model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Personal(); $user = new User(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->user_id]); } else { return $this->render('create', ['model' => $model, 'user' => $user]); } }
/** * Creates a new Personal model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Personal(); $user = new User(); if ($model->load(Yii::$app->request->post()) && $user->load(Yii::$app->request->post())) { $user->auth_key = Yii::$app->security->generateRandomString(); $user->password_hash = Yii::$app->security->generatePasswordHash($user->password_hash); if ($user->save()) { $model->user_id = $user->id; $model->save(); } return $this->redirect(['view', 'id' => $model->user_id]); } else { return $this->render('create', ['model' => $model, 'user' => $user]); } }