diff --git a/common/config/.gitignore b/common/config/.gitignore new file mode 100644 index 0000000..22258e4 --- /dev/null +++ b/common/config/.gitignore @@ -0,0 +1 @@ +main-local.php \ No newline at end of file diff --git a/common/config/main-local.php b/common/config/main-local.php index fc2943b..f47e800 100755 --- a/common/config/main-local.php +++ b/common/config/main-local.php @@ -3,9 +3,9 @@ return [ 'components' => [ 'db' => [ 'class' => 'yii\db\Connection', - 'dsn' => 'pgsql:host=127.0.0.1;port=5432;dbname=mfp_local', - 'username' => 'postgres', - 'password' => '', + 'dsn' => 'pgsql:host=195.248.225.149;port=5432;dbname=mfp', + 'username' => 'test33', + 'password' => 'E4q2N7i9', 'schemaMap' => [ 'pgsql'=> [ 'class'=>'yii\db\pgsql\Schema', diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index 32508b3..ddba771 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -3,7 +3,8 @@ namespace frontend\controllers; use Yii; use common\models\User; -use yii\data\ActiveDataProvider; +use common\models\UserInfo; + use yii\filters\AccessControl; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -39,17 +40,15 @@ class AccountsController extends Controller { - $model = $this->findModel(Yii::$app->user->identity->id); - + $user = $this->findUser(Yii::$app->user->identity->id); - if ($model->load(Yii::$app->request->post()) && $model->validate()) { + $user_info = $this->findUserInfo(Yii::$app->user->identity->id); - $model->save(); - } return $this->render('cabinet', [ - 'model' => $model + 'user' => $user, + 'user_info' => $user_info, ]); @@ -59,7 +58,7 @@ class AccountsController extends Controller - protected function findModel($id) + protected function findUser($id) { if (($model = User::findOne(["id"=>$id])) !== null) { @@ -71,4 +70,15 @@ class AccountsController extends Controller + protected function findUserInfo($id) + { + + if (($model = UserInfo::findOne(["user_id"=>$id])) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + } diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 22717c7..197d72f 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -1,6 +1,7 @@ load(Yii::$app->request->post())) { if ($user = $model->signup()) { + + $user_info = new UserInfo(); + + $user_info->user_id = $user->id; + + $user_info->save(); + if (Yii::$app->getUser()->login($user)) { return $this->goHome(); } diff --git a/frontend/views/accounts/cabinet.php b/frontend/views/accounts/cabinet.php index e2ac4d5..d674151 100755 --- a/frontend/views/accounts/cabinet.php +++ b/frontend/views/accounts/cabinet.php @@ -1,9 +1,59 @@ title = 'Мой профиль'; $this->params['breadcrumbs'][] = $this->title; ?>