Настроен behaviors для профиля
This commit is contained in:
parent
028cce3bef
commit
1ee8f198ac
@ -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,32 +42,29 @@ class UserCardController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
if(Yii::$app->user->isGuest) return $this->render('index', ['info' => '<h3>Пожалуйста, авторизируйтесь!</h3>']);
|
$id_user = Yii::$app->user->id;
|
||||||
else {
|
$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) {
|
if($result) {
|
||||||
$id = $result[0]['id'];
|
$id = $result[0]['id'];
|
||||||
$dataProvider = new ActiveDataProvider([
|
$dataProvider = new ActiveDataProvider([
|
||||||
'query' => FieldsValueNew::find()
|
'query' => FieldsValueNew::find()
|
||||||
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE])
|
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE])
|
||||||
->orderBy('order'),
|
->orderBy('order'),
|
||||||
'pagination' => [
|
'pagination' => [
|
||||||
'pageSize' => 200,
|
'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', [
|
return $this->render('view', [
|
||||||
'model' => $this->findModel($id),
|
'model' => $this->findModel($id),
|
||||||
'modelFildValue' => $dataProvider,
|
'modelFildValue' => $dataProvider,
|
||||||
'skills' => $skills,
|
'skills' => $skills,
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
else return $this->render('index', ['info' => '<h3>Ваши личные данные не заненсены в базу.</h3>']);
|
|
||||||
}
|
}
|
||||||
|
else return $this->render('index', ['info' => '<h3>Ваши личные данные не заненсены в базу.</h3>']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user