Commit 9845be0366ef9c4364fb14614ad0dadc04222777
1 parent
fbdb1f1c
test
Showing
1 changed file
with
21 additions
and
7 deletions
Show diff stats
frontend/controllers/AccountsController.php
1 | <?php | 1 | <?php |
2 | namespace frontend\controllers; | 2 | namespace frontend\controllers; |
3 | 3 | ||
4 | +use common\models\Language; | ||
4 | use Yii; | 5 | use Yii; |
5 | use common\models\User; | 6 | use common\models\User; |
6 | -use yii\data\ActiveDataProvider; | 7 | +use common\models\UserInfo; |
8 | + | ||
7 | use yii\filters\AccessControl; | 9 | use yii\filters\AccessControl; |
8 | use yii\web\Controller; | 10 | use yii\web\Controller; |
9 | use yii\web\NotFoundHttpException; | 11 | use yii\web\NotFoundHttpException; |
@@ -39,17 +41,18 @@ class AccountsController extends Controller | @@ -39,17 +41,18 @@ class AccountsController extends Controller | ||
39 | { | 41 | { |
40 | 42 | ||
41 | 43 | ||
42 | - $model = $this->findModel(Yii::$app->user->identity->id); | 44 | + $user = $this->findUser(Yii::$app->user->identity->id); |
43 | 45 | ||
46 | + $user_info = $this->findUserInfo(Yii::$app->user->identity->id); | ||
44 | 47 | ||
45 | - if ($model->load(Yii::$app->request->post()) && $model->validate()) { | 48 | + $langs = Language::getActiveLanguages(); |
46 | 49 | ||
47 | - $model->save(); | ||
48 | 50 | ||
49 | - } | ||
50 | 51 | ||
51 | return $this->render('cabinet', [ | 52 | return $this->render('cabinet', [ |
52 | - 'model' => $model | 53 | + 'user' => $user, |
54 | + 'user_info' => $user_info, | ||
55 | + 'langs' => $langs, | ||
53 | ]); | 56 | ]); |
54 | 57 | ||
55 | 58 | ||
@@ -64,7 +67,7 @@ class AccountsController extends Controller | @@ -64,7 +67,7 @@ class AccountsController extends Controller | ||
64 | 67 | ||
65 | 68 | ||
66 | 69 | ||
67 | - protected function findModel($id) | 70 | + protected function findUser($id) |
68 | { | 71 | { |
69 | 72 | ||
70 | if (($model = User::findOne(["id"=>$id])) !== null) { | 73 | if (($model = User::findOne(["id"=>$id])) !== null) { |
@@ -76,4 +79,15 @@ class AccountsController extends Controller | @@ -76,4 +79,15 @@ class AccountsController extends Controller | ||
76 | 79 | ||
77 | 80 | ||
78 | 81 | ||
82 | + protected function findUserInfo($id) | ||
83 | + { | ||
84 | + | ||
85 | + if (($model = UserInfo::findOne(["user_id"=>$id])) !== null) { | ||
86 | + return $model; | ||
87 | + } else { | ||
88 | + throw new NotFoundHttpException('The requested page does not exist.'); | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
92 | + | ||
79 | } | 93 | } |