diff --git a/backend/modules/card/controllers/UserCardController.php b/backend/modules/card/controllers/UserCardController.php index 10da2a8..4c861c1 100755 --- a/backend/modules/card/controllers/UserCardController.php +++ b/backend/modules/card/controllers/UserCardController.php @@ -6,11 +6,11 @@ use backend\modules\card\models\ResumeTemplate; use backend\modules\card\models\UserCard; use backend\modules\card\models\UserCardSearch; use backend\modules\settings\models\Skill; -use common\classes\Debug; use common\models\AchievementUserCard; use common\models\CardSkill; use common\models\FieldsValueNew; use common\models\User; +use common\models\UserCardPortfolioProjects; use kartik\mpdf\Pdf; use Yii; use yii\data\ActiveDataProvider; @@ -118,6 +118,13 @@ class UserCardController extends Controller ] ]); + $portfolioProjects = new ActiveDataProvider([ + 'query' => UserCardPortfolioProjects::find()->where(['card_id' => $id]), + 'pagination' => [ + 'pageSize' => 200, + ] + ]); + return $this->render('view', [ 'model' => $this->findModel($id), 'modelFieldValue' => $dataProvider, @@ -125,6 +132,7 @@ class UserCardController extends Controller 'achievements' => $achievements, 'userData' => User::findOne($id_current_user), 'changeDataProvider' => $changeDataProvider, + 'portfolioProjects' => $portfolioProjects ]); } diff --git a/backend/modules/card/models/UserCard.php b/backend/modules/card/models/UserCard.php index 9d032f8..c25b8bb 100755 --- a/backend/modules/card/models/UserCard.php +++ b/backend/modules/card/models/UserCard.php @@ -2,16 +2,11 @@ namespace backend\modules\card\models; -use backend\modules\achievements\models\Achievement; -use Common\Behaviors\LogBehavior; use common\models\AchievementUserCard; -use Yii; -use backend\modules\settings\models\Skill; -use common\classes\Debug; use common\models\CardSkill; -use common\models\User; -use common\models\FieldsValue; use common\models\FieldsValueNew; +use common\models\UserCardPortfolioProjects; +use Yii; use yii\helpers\ArrayHelper; class UserCard extends \common\models\UserCard @@ -19,6 +14,7 @@ class UserCard extends \common\models\UserCard public $fields; public $skill; public $achievements; + public $portfolioProjects; public function init() { @@ -79,6 +75,40 @@ class UserCard extends \common\models\UserCard if (!empty($achievements)) { $this->achievements = $achievements; } + + /** @var UserCardPortfolioProjects[] $portfolioProjects */ + $portfolioProjects = UserCardPortfolioProjects::find() + ->where(['card_id' => \Yii::$app->request->get('id')]) + ->all(); + + $array = []; + if (!empty($portfolioProjects)) { + foreach ($portfolioProjects as $item) { + array_push( + $array, + [ + 'id' => $item->id, + 'title' => $item->title, + 'description' => $item->description, + 'main_stack' => $item->main_stack, + 'additional_stack' => $item->additional_stack, + 'link' => $item->link + ] + ); + } + $this->portfolioProjects = $array; + } else { + $this->portfolioProjects = [ + [ + 'id' => null, + 'title' => null, + 'description' => null, + 'main_stack' => null, + 'additional_stack' => null, + 'link' => null + ] + ]; + } } public function behaviors() @@ -135,6 +165,22 @@ class UserCard extends \common\models\UserCard } } + if(array_key_exists('portfolioProjects', $post) && is_array($post['portfolioProjects'])){ + UserCardPortfolioProjects::deleteAll(['card_id' => $this->id]); + + foreach ($post['portfolioProjects'] as $item) { + $portfolioProject = new UserCardPortfolioProjects(); + $portfolioProject->card_id = $this->id; + $portfolioProject->title = $item['title']; + $portfolioProject->description = $item['description']; + $portfolioProject->main_stack = $item['main_stack']; + $portfolioProject->additional_stack = $item['additional_stack']; + $portfolioProject->link = $item['link']; + + $portfolioProject->save(); + } + } + if(array_key_exists('achievements', $post) && is_array($post['achievements'])){ AchievementUserCard::deleteAll(['user_card_id' => $this->id]); diff --git a/backend/modules/card/views/user-card/_form.php b/backend/modules/card/views/user-card/_form.php index 109b359..70d8658 100755 --- a/backend/modules/card/views/user-card/_form.php +++ b/backend/modules/card/views/user-card/_form.php @@ -223,6 +223,60 @@ use yii\widgets\ActiveForm; +
+ Требуемые параметры: +
++ Параметры + | ++ Значение + | +
---|---|
+ card_id + | ++ Id профиля пользователя + | +
+ Возвращает массив объектов Проект в портфолио.
+ Ответ имеет следующий вид:
+
+ Возвращаемые параметры: +
++ Параметры + | ++ Значение + | +
---|---|
+ id + | ++ Id + | +
+ title + | ++ название + | +
+ description + | ++ описание + | +
+ main_stack + | ++ основной язык проекта + | +
+ additional_stack + | ++ используемые технологии + | +
+ link + | ++ ссылка на репозиторий + | +