user card level

This commit is contained in:
andrey 2021-06-30 17:30:53 +03:00
parent 8c9b5f04d4
commit 74ada385f5
5 changed files with 70 additions and 3 deletions

View File

@ -129,6 +129,14 @@ use yii\widgets\ActiveForm;
</div> </div>
</div> </div>
<div class="row">
<div class="col-xs-6">
<?= $form->field($model, 'level')->dropDownList(
\common\models\UserCard::getLevelList(),
['prompt' => '...']
) ?>
</div>
</div>
<div class="row"> <div class="row">

View File

@ -35,6 +35,12 @@ $this->params['breadcrumbs'][] = $this->title;
return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']); return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']);
} }
], ],
[
'attribute' => 'level',
'value' => function($model){
return \common\models\UserCard::getLevelLabel($model->level);
}
],
[ [
'attribute' => 'resume', 'attribute' => 'resume',
'format' => 'raw', 'format' => 'raw',

View File

@ -29,6 +29,7 @@ use yii\helpers\ArrayHelper;
* @property string $vc_text * @property string $vc_text
* @property int $position_id * @property int $position_id
* @property int $city * @property int $city
* @property int $level
* *
* @property FieldsValue[] $fieldsValues * @property FieldsValue[] $fieldsValues
* @property ProjectUser[] $projectUsers * @property ProjectUser[] $projectUsers
@ -40,6 +41,33 @@ class UserCard extends \yii\db\ActiveRecord
const GENDER_M = 0; const GENDER_M = 0;
const GENDER_W = 1; const GENDER_W = 1;
const LEVEL_JUNIOR = 1;
const LEVEL_MIDDLE = 2;
const LEVEL_MIDDLE_PLUS = 3;
const LEVEL_SENIOR = 4;
/**
* @return string[]
*/
public static function getLevelList(): array
{
return [
self::LEVEL_JUNIOR => 'Junior',
self::LEVEL_MIDDLE => 'Middle',
self::LEVEL_MIDDLE_PLUS => 'Middle+',
self::LEVEL_SENIOR => 'Senior',
];
}
/**
* @param int $level
* @return string
*/
public static function getLevelLabel(int $level): string
{
return self::getLevelList()[$level];
}
public function behaviors() public function behaviors()
{ {
return [ return [
@ -67,7 +95,7 @@ class UserCard extends \yii\db\ActiveRecord
{ {
return [ return [
[['fio', 'status', 'gender', 'email'], 'required'], [['fio', 'status', 'gender', 'email'], 'required'],
[['gender', 'status', 'position_id', 'id_user'], 'integer'], [['gender', 'status', 'position_id', 'id_user', 'level'], 'integer'],
[['dob', 'created_at', 'updated_at', 'deleted_at', 'vc_text'], 'safe'], [['dob', 'created_at', 'updated_at', 'deleted_at', 'vc_text'], 'safe'],
[['fio', 'passport', 'photo', 'email', 'resume', 'city', 'link_vk', 'link_telegram'], 'string', 'max' => 255], [['fio', 'passport', 'photo', 'email', 'resume', 'city', 'link_vk', 'link_telegram'], 'string', 'max' => 255],
[['salary'], 'string', 'max' => 100], [['salary'], 'string', 'max' => 100],
@ -100,7 +128,8 @@ class UserCard extends \yii\db\ActiveRecord
'city' => 'Город', 'city' => 'Город',
'link_vk' => 'VK', 'link_vk' => 'VK',
'link_telegram' => 'Telegram', 'link_telegram' => 'Telegram',
'vc_text' => 'Резюме текст' 'vc_text' => 'Резюме текст',
'level' => 'Уровень'
]; ];
} }

View File

@ -0,0 +1,25 @@
<?php
use yii\db\Migration;
/**
* Handles adding columns to table `{{%user_card}}`.
*/
class m210630_140410_add_level_column_to_user_card_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('{{%user_card}}', 'level', $this->integer(1)->defaultValue(2));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('{{%user_card}}', 'level');
}
}

View File

@ -58,7 +58,6 @@ class ProfileSearchForm extends Model
if($this->skills){ if($this->skills){
$model->joinWith(['skillValues']); $model->joinWith(['skillValues']);
Debug::prn(123);
$this->skills = explode(',', $this->skills); $this->skills = explode(',', $this->skills);
$model->where(['card_skill.skill_id' => $this->skills]); $model->where(['card_skill.skill_id' => $this->skills]);
} }