Help.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. use yii\behaviors\SluggableBehavior;
  5. /**
  6. * This is the model class for table "help".
  7. *
  8. * @property integer $id
  9. * @property string $title
  10. * @property string $h1
  11. * @property string $short_text
  12. * @property string $text
  13. * @property string $description
  14. * @property string $key_words
  15. * @property integer $cat_id
  16. * @property string $slug
  17. * @property integer $created_at
  18. *
  19. * @property HelpCategory $cat
  20. */
  21. class Help extends \yii\db\ActiveRecord
  22. {
  23. /**
  24. * @inheritdoc
  25. */
  26. public static function tableName()
  27. {
  28. return 'help';
  29. }
  30. public function behaviors()
  31. {
  32. return [
  33. [
  34. 'class' => SluggableBehavior::className(),
  35. 'attribute' => 'title',
  36. 'slugAttribute' => 'slug',
  37. ]
  38. ];
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function rules()
  44. {
  45. return [
  46. [['title', 'h1', 'short_text', 'text', 'description', 'key_words', 'cat_id', 'slug'], 'required'],
  47. [['short_text', 'text'], 'string'],
  48. [['cat_id', 'created_at'], 'integer'],
  49. [['title', 'h1', 'description', 'key_words', 'slug'], 'string', 'max' => 255],
  50. [['cat_id'], 'exist', 'skipOnError' => true, 'targetClass' => HelpCategory::className(), 'targetAttribute' => ['cat_id' => 'id']],
  51. ];
  52. }
  53. /**
  54. * @inheritdoc
  55. */
  56. public function attributeLabels()
  57. {
  58. return [
  59. 'id' => Yii::t('app', 'ID'),
  60. 'title' => Yii::t('app', 'Title'),
  61. 'h1' => Yii::t('app', 'H1'),
  62. 'short_text' => Yii::t('app', 'Short Text'),
  63. 'text' => Yii::t('app', 'Text'),
  64. 'description' => Yii::t('app', 'Description'),
  65. 'key_words' => Yii::t('app', 'Key Words'),
  66. 'cat_id' => Yii::t('app', 'Cat ID'),
  67. 'slug' => Yii::t('app', 'Slug'),
  68. 'created_at' => Yii::t('app', 'Created At'),
  69. ];
  70. }
  71. /**
  72. * @return \yii\db\ActiveQuery
  73. */
  74. public function getCat()
  75. {
  76. return $this->hasOne(HelpCategory::className(), ['id' => 'cat_id']);
  77. }
  78. }