Achievements in fronted card

This commit is contained in:
Korzinkayablok 2021-09-13 13:37:59 +03:00
parent 90d464feae
commit 1d4cf536e5
3 changed files with 23 additions and 2 deletions

View File

@ -103,7 +103,7 @@ $this->params['breadcrumbs'][] = $this->title;
href="<? echo \yii\helpers\Url::to(['/achievements/achievements/view', 'id' => $achievement['achievement']->id]);?>" href="<? echo \yii\helpers\Url::to(['/achievements/achievements/view', 'id' => $achievement['achievement']->id]);?>"
class="btn btn-default btn-sm"> class="btn btn-default btn-sm">
<?= Html::tag('img', null, <?= Html::tag('img', null,
['src' => $achievement['achievement']->img, 'height' => '50px', 'alt'=> $achievement['achievement']->title] ['src' => $achievement['achievement']->img, 'height' => '50px', 'width' => '50px', 'alt'=> $achievement['achievement']->title]
) ?> ) ?>
<?= $achievement['achievement']->title; ?> <?= $achievement['achievement']->title; ?>
</a> </a>

View File

@ -4,6 +4,7 @@
namespace frontend\modules\card\controllers; namespace frontend\modules\card\controllers;
use common\classes\Debug; use common\classes\Debug;
use common\models\AchievementUserCard;
use common\models\CardSkill; use common\models\CardSkill;
use common\models\FieldsValueNew; use common\models\FieldsValueNew;
use common\models\User; use common\models\User;
@ -60,10 +61,18 @@ class UserCardController extends Controller
]); ]);
$skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all(); $skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all();
$achievements = AchievementUserCard::find()
->where(['user_card_id' => $id])
->innerJoinWith(['achievement' => function($query) {
$query->andWhere(['status' => \common\models\Achievement::STATUS_ACTIVE]);
}])
->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,
'achievements' => $achievements,
]); ]);
} }
else return $this->render('index', ['info' => '<h3>Ваши личные данные не заненсены в базу.</h3>']); else return $this->render('index', ['info' => '<h3>Ваши личные данные не заненсены в базу.</h3>']);

View File

@ -7,6 +7,7 @@ use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $skills \common\models\CardSkill */ /* @var $skills \common\models\CardSkill */
/* @var $skill \common\models\Skill */ /* @var $skill \common\models\Skill */
/* @var $achievements \common\models\Achievement */
/* @var $modelFildValue yii\data\ActiveDataProvider */ /* @var $modelFildValue yii\data\ActiveDataProvider */
/* @var $model */ /* @var $model */
@ -31,13 +32,24 @@ $this->title = 'Профиль';
], ],
]); ]);
?> ?>
<h2>Навыки</h2> <h2>Навыки</h2>
<?php foreach ($skills as $skill) : ?> <?php foreach ($skills as $skill) : ?>
<span class="btn btn-default btn-sm"><?= $skill['skill']->name; ?></span> <span class="btn btn-default btn-sm"><?= $skill['skill']->name; ?></span>
<?php endforeach; ?> <?php endforeach; ?>
<h2>Достижения</h2>
<?php foreach ($achievements as $achievement) : ?>
<a target="_blank"
href="<? echo \yii\helpers\Url::to(['/achievements/achievements/view', 'id' => $achievement['achievement']->id]);?>"
class="btn btn-default btn-sm">
<?= Html::tag('img', null,
['src' => $achievement['achievement']->img, 'height' => '50px','width' => '50px', 'alt'=> $achievement['achievement']->title]
) ?>
<?= $achievement['achievement']->title; ?>
</a>
<?php endforeach; ?>
<h2>Дополнительные сведения</h2> <h2>Дополнительные сведения</h2>
<?= GridView::widget([ <?= GridView::widget([