HelpCategory.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. use yii\behaviors\SluggableBehavior;
  5. /**
  6. * This is the model class for table "help_category".
  7. *
  8. * @property integer $id
  9. * @property string $title
  10. * @property string $description
  11. * @property string $key_words
  12. * @property string $slug
  13. *
  14. * @property Help[] $helps
  15. */
  16. class HelpCategory extends \yii\db\ActiveRecord
  17. {
  18. /**
  19. * @inheritdoc
  20. */
  21. public static function tableName()
  22. {
  23. return 'help_category';
  24. }
  25. public function behaviors()
  26. {
  27. return [
  28. [
  29. 'class' => SluggableBehavior::className(),
  30. 'attribute' => 'title',
  31. 'slugAttribute' => 'slug',
  32. ]
  33. ];
  34. }
  35. /**
  36. * @inheritdoc
  37. */
  38. public function rules()
  39. {
  40. return [
  41. [['title', 'description', 'key_words'], 'required'],
  42. [['title', 'description', 'key_words', 'slug'], 'string', 'max' => 255],
  43. ];
  44. }
  45. /**
  46. * @inheritdoc
  47. */
  48. public function attributeLabels()
  49. {
  50. return [
  51. 'id' => Yii::t('app', 'ID'),
  52. 'title' => Yii::t('app', 'Title'),
  53. 'description' => Yii::t('app', 'Description'),
  54. 'key_words' => Yii::t('app', 'Key Words'),
  55. 'slug' => Yii::t('app', 'Slug'),
  56. ];
  57. }
  58. /**
  59. * @return \yii\db\ActiveQuery
  60. */
  61. public function getHelps()
  62. {
  63. return $this->hasMany(Help::className(), ['cat_id' => 'id']);
  64. }
  65. }