skill category

This commit is contained in:
andrey
2021-06-08 17:05:54 +03:00
parent 9f1db817a5
commit 23773eff4e
13 changed files with 487 additions and 0 deletions

View File

@ -9,6 +9,7 @@ use Yii;
*
* @property int $id
* @property string $name
* @property integer $category_id
*
* @property CardSkill[] $cardSkills
*/
@ -29,6 +30,7 @@ class Skill extends \yii\db\ActiveRecord
{
return [
[['name'], 'required'],
[['category_id'], 'integer'],
[['name'], 'string', 'max' => 100],
];
}
@ -51,4 +53,9 @@ class Skill extends \yii\db\ActiveRecord
{
return $this->hasMany(CardSkill::className(), ['skill_id' => 'id']);
}
public function getCategory()
{
return $this->hasOne(SkillCategory::class, ['id' => 'category_id']);
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "skill_category".
*
* @property int $id
* @property string $name
*
* @property Skill[] $skills
*/
class SkillCategory extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'skill_category';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['name'], 'required'],
[['name'], 'string', 'max' => 255],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Name',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getSkills()
{
return $this->hasMany(Skill::className(), ['category' => 'id']);
}
public static function getAll()
{
return self::find()->all();
}
}