From 1ee8f198acc7d8265376f053bd245c2d70511f52 Mon Sep 17 00:00:00 2001 From: Glambertessa Date: Mon, 18 Nov 2019 17:04:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B5?= =?UTF-8?q?=D0=BD=20behaviors=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=84=D0=B8=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../card/controllers/UserCardController.php | 63 ++++++++++++------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/frontend/modules/card/controllers/UserCardController.php b/frontend/modules/card/controllers/UserCardController.php index 02e3d8b..86bf120 100644 --- a/frontend/modules/card/controllers/UserCardController.php +++ b/frontend/modules/card/controllers/UserCardController.php @@ -8,11 +8,33 @@ use common\models\FieldsValueNew; use Yii; use frontend\modules\card\models\UserCard; use yii\data\ActiveDataProvider; +use yii\filters\AccessControl; +use yii\filters\VerbFilter; use yii\web\Controller; use yii\web\NotFoundHttpException; class UserCardController extends Controller { + + /** + * {@inheritdoc} + */ + public function behaviors() + { + return [ + 'access' => [ + 'class' => AccessControl::className(), + 'only' => ['index', 'update'], + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['@'], + ], + ], + ], + ]; + } + /** * Displays a single Product model. * @return mixed @@ -20,32 +42,29 @@ class UserCardController extends Controller */ public function actionIndex() { - if(Yii::$app->user->isGuest) return $this->render('index', ['info' => '

Пожалуйста, авторизируйтесь!

']); - else { - $id_user = Yii::$app->user->id; - $result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); + $id_user = Yii::$app->user->id; + $result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); - if($result) { - $id = $result[0]['id']; - $dataProvider = new ActiveDataProvider([ - 'query' => FieldsValueNew::find() - ->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE]) - ->orderBy('order'), - 'pagination' => [ - 'pageSize' => 200, - ], - ]); + if($result) { + $id = $result[0]['id']; + $dataProvider = new ActiveDataProvider([ + 'query' => FieldsValueNew::find() + ->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE]) + ->orderBy('order'), + 'pagination' => [ + 'pageSize' => 200, + ], + ]); - $skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all(); + $skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all(); - return $this->render('view', [ - 'model' => $this->findModel($id), - 'modelFildValue' => $dataProvider, - 'skills' => $skills, - ]); - } - else return $this->render('index', ['info' => '

Ваши личные данные не заненсены в базу.

']); + return $this->render('view', [ + 'model' => $this->findModel($id), + 'modelFildValue' => $dataProvider, + 'skills' => $skills, + ]); } + else return $this->render('index', ['info' => '

Ваши личные данные не заненсены в базу.

']); } /**