Настроен behaviors для профиля

This commit is contained in:
Glambertessa 2019-11-18 17:04:32 +03:00
parent 028cce3bef
commit 1ee8f198ac

View File

@ -8,11 +8,33 @@ use common\models\FieldsValueNew;
use Yii; use Yii;
use frontend\modules\card\models\UserCard; use frontend\modules\card\models\UserCard;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
class UserCardController extends Controller 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. * Displays a single Product model.
* @return mixed * @return mixed
@ -20,8 +42,6 @@ class UserCardController extends Controller
*/ */
public function actionIndex() public function actionIndex()
{ {
if(Yii::$app->user->isGuest) return $this->render('index', ['info' => '<h3>Пожалуйста, авторизируйтесь!</h3>']);
else {
$id_user = Yii::$app->user->id; $id_user = Yii::$app->user->id;
$result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all(); $result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all();
@ -46,7 +66,6 @@ class UserCardController extends Controller
} }
else return $this->render('index', ['info' => '<h3>Ваши личные данные не заненсены в базу.</h3>']); else return $this->render('index', ['info' => '<h3>Ваши личные данные не заненсены в базу.</h3>']);
} }
}
/** /**
* Updates an existing UserCard model. * Updates an existing UserCard model.