skill category
This commit is contained in:
@ -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']);
|
||||
}
|
||||
}
|
||||
|
59
common/models/SkillCategory.php
Normal file
59
common/models/SkillCategory.php
Normal 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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user