update resume method

This commit is contained in:
iIronside 2023-11-08 12:06:22 +03:00
parent 4c7e6f3d28
commit bc4cb3b54c
4 changed files with 121 additions and 4 deletions

View File

@ -231,6 +231,6 @@ class User extends ActiveRecord implements IdentityInterface, UserRbacInterface
public function getProjectUser()
{
return $this->hasMany(ProjectUser::className(), ['user_id' => 'id']);
return $this->hasMany(ProjectUser::class, ['user_id' => 'id']);
}
}

View File

@ -0,0 +1,74 @@
<?php
namespace frontend\modules\api\models;
/**
*
* @OA\Schema(
* schema="UserCardPortfolioProjects",
* @OA\Property(
* property="title",
* type="string",
* description="Название"
* ),
* @OA\Property(
* property="description",
* type="string",
* description="Описание проекта"
* ),
* @OA\Property(
* property="main_stack",
* type="string",
* description="Основная технология"
* ),
* @OA\Property(
* property="additional_stack",
* type="string",
* description="Дополнительные технологии"
* ),
* @OA\Property(
* property="link",
* type="string",
* description="Ссылка"
* ),
*)
*
* @OA\Schema(
* schema="UserCardPortfolioProjectsExample",
* type="array",
* @OA\Items(
* ref="#/components/schemas/UserCardPortfolioProjects",
* ),
*)
*
* @property Skill $mainStack
*/
class UserCardPortfolioProjects extends \common\models\UserCardPortfolioProjects
{
public function fields(): array
{
return [
'title',
'description',
'main_stack' => function () {
return $this->mainStack->name;
},
'additional_stack',
'link',
];
}
/**
* @return string[]
*/
public function extraFields(): array
{
return [];
}
public function getMainStack()
{
return $this->hasOne(Skill::class, ['id' => 'main_stack']);
}
}

View File

@ -2,12 +2,26 @@
namespace frontend\modules\api\models\resume;
use yii\helpers\ArrayHelper;
use frontend\modules\card\models\UserCard;
/**
*
* @OA\Schema(
* schema="Resume",
* type="array",
* @OA\Items(
* @OA\Property(
* property="fio",
* type="string",
* example="ФИО",
* description="ФИО"
* ),
* @OA\Property(
* property="position",
* type="string",
* example="position",
* description="Специализация"
* ),
* @OA\Property(
* property="stack",
* type="array",
@ -23,6 +37,11 @@ use yii\helpers\ArrayHelper;
* example="Резюме",
* description="Тело резюме в HTML разметке"
* ),
* @OA\Property(
* property="projects",
* ref="#/components/schemas/UserCardPortfolioProjectsExample",
* ),
* ),
*)
*
* @OA\Schema(
@ -32,23 +51,37 @@ use yii\helpers\ArrayHelper;
* ref="#/components/schemas/Resume",
* ),
*)
* @property UserCard $userCard
*/
class Resume extends \common\models\User
{
/**
* @return string[]
*/
public function fields(): array
{
return [
'stack' => function() {
'fio' => function () {
return $this->userCard->fio;
},
'position' => function () {
return $this->userCard->position->name;
},
'stack' => function () {
return $this->userCard->getSkillsName();
},
'resume' => function () {
return $this->userCard->vc_text;
},
'projects' => function () {
return $this->userCard->userCardPortfolioProjects;
},
];
}
public function getUserCard()
{
return $this->hasOne(UserCard::class, ['id_user' => 'id']);
}
}

View File

@ -3,9 +3,14 @@
namespace frontend\modules\card\models;
use common\models\CardSkill;
use frontend\modules\api\models\UserCardPortfolioProjects;
use Yii;
use yii\db\ActiveQuery;
use yii\helpers\ArrayHelper;
/**
* @property UserCardPortfolioProjects[] $userCardPortfolioProjects
*/
class UserCard extends \common\models\UserCard
{
public $fields;
@ -48,4 +53,9 @@ class UserCard extends \common\models\UserCard
{
return self::findOne(['id_user' => $userId]);
}
public function getUserCardPortfolioProjects(): ActiveQuery
{
return $this->hasMany(UserCardPortfolioProjects::class, ['card_id' => 'id']);
}
}