add skill and position
This commit is contained in:
67
common/models/CardSkill.php
Normal file
67
common/models/CardSkill.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "card_skill".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $card_id
|
||||
* @property int $skill_id
|
||||
*
|
||||
* @property Skill $skill
|
||||
* @property UserCard $card
|
||||
*/
|
||||
class CardSkill extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'card_skill';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['card_id', 'skill_id'], 'required'],
|
||||
[['card_id', 'skill_id'], 'integer'],
|
||||
[['skill_id'], 'exist', 'skipOnError' => true, 'targetClass' => Skill::className(), 'targetAttribute' => ['skill_id' => 'id']],
|
||||
[['card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['card_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'card_id' => 'Card ID',
|
||||
'skill_id' => 'Skill ID',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getSkill()
|
||||
{
|
||||
return $this->hasOne(Skill::className(), ['id' => 'skill_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->hasOne(UserCard::className(), ['id' => 'card_id']);
|
||||
}
|
||||
}
|
44
common/models/Position.php
Normal file
44
common/models/Position.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "position".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
*/
|
||||
class Position extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'position';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name'], 'required'],
|
||||
[['name'], 'string', 'max' => 100],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => 'Название',
|
||||
];
|
||||
}
|
||||
}
|
54
common/models/Skill.php
Normal file
54
common/models/Skill.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "skill".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
*
|
||||
* @property CardSkill[] $cardSkills
|
||||
*/
|
||||
class Skill extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'skill';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name'], 'required'],
|
||||
[['name'], 'string', 'max' => 100],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => 'Name',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getCardSkills()
|
||||
{
|
||||
return $this->hasMany(CardSkill::className(), ['skill_id' => 'id']);
|
||||
}
|
||||
}
|
@ -21,10 +21,11 @@ use yii\db\Expression;
|
||||
* @property string $updated_at
|
||||
* @property string $resume
|
||||
* @property string $salary
|
||||
* @property int $position_id
|
||||
*
|
||||
* @property array $genders
|
||||
* @property string $gendersText
|
||||
*
|
||||
* @property FieldsValue[] $fieldsValues
|
||||
* @property ProjectUser[] $projectUsers
|
||||
* @property Position $position
|
||||
* @property Status $status0
|
||||
*/
|
||||
class UserCard extends \yii\db\ActiveRecord
|
||||
@ -59,11 +60,11 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
{
|
||||
return [
|
||||
[['fio', 'status'], 'required'],
|
||||
[['status'], 'integer'],
|
||||
[['gender'], 'in', 'range' => array_keys($this->genders)],
|
||||
[['gender', 'status', 'position_id'], 'integer'],
|
||||
[['dob', 'created_at', 'updated_at'], 'safe'],
|
||||
[['fio', 'passport', 'photo', 'email', 'resume'], 'string', 'max' => 255],
|
||||
[['salary'], 'string', 'max' => 100],
|
||||
[['position_id'], 'exist', 'skipOnError' => true, 'targetClass' => Position::class, 'targetAttribute' => ['position_id' => 'id']],
|
||||
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
|
||||
];
|
||||
}
|
||||
@ -86,6 +87,7 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
'updated_at' => 'Дата редактирование',
|
||||
'resume' => 'Резюме',
|
||||
'salary' => 'Зарплата',
|
||||
'position_id' => 'Должность',
|
||||
];
|
||||
}
|
||||
|
||||
@ -105,6 +107,14 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
return $this->hasMany(ProjectUser::class, ['card_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getPosition()
|
||||
{
|
||||
return $this->hasOne(Position::class, ['id' => 'position_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
|
Reference in New Issue
Block a user