Article.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace frontend\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "bit_article".
  6. *
  7. * @property integer $id
  8. * @property string $create_date
  9. * @property string $modify_date
  10. * @property string $author
  11. * @property string $content
  12. * @property integer $down
  13. * @property integer $hits
  14. * @property string $image_path
  15. * @property boolean $is_publication
  16. * @property boolean $is_recommend
  17. * @property boolean $is_top
  18. * @property string $link_url
  19. * @property string $meta_description
  20. * @property string $meta_keywords
  21. * @property string $min_content
  22. * @property string $sub_title
  23. * @property string $title
  24. * @property integer $up
  25. * @property integer $article_category_id
  26. * @property string $createdatea
  27. * @property string $modifydatea
  28. * @property string $meta_imge
  29. */
  30. class Article extends \yii\db\ActiveRecord
  31. {
  32. /**
  33. * @inheritdoc
  34. */
  35. public static function tableName()
  36. {
  37. return 'bit_article';
  38. }
  39. public static function getDb()
  40. {
  41. return Yii::$app->get('dbXcoq');
  42. }
  43. /**
  44. * @inheritdoc
  45. */
  46. public function rules()
  47. {
  48. return [
  49. [['create_date', 'modify_date', 'createdatea', 'modifydatea'], 'safe'],
  50. [['content', 'content1','content2','hits', 'title','title1','title2', 'article_category_id'], 'required'],
  51. [['content', 'content1','content2','min_content'], 'string'],
  52. [['down', 'hits', 'up', 'article_category_id'], 'integer'],
  53. [['is_publication', 'is_recommend', 'is_top'], 'boolean'],
  54. [['author','author1','author2', 'image_path', 'link_url', 'sub_title','sub_title1','sub_title2', 'title', 'title1','title2','meta_imge'], 'string', 'max' => 255],
  55. [['meta_description', 'meta_keywords'], 'string', 'max' => 3000],
  56. ];
  57. }
  58. /**
  59. * @inheritdoc
  60. */
  61. public function attributeLabels()
  62. {
  63. return [
  64. 'id' => 'ID',
  65. 'create_date' => 'Create Date',
  66. 'modify_date' => 'Modify Date',
  67. 'author' => 'Author',
  68. 'content' => 'Content',
  69. 'down' => 'Down',
  70. 'hits' => 'Hits',
  71. 'image_path' => 'Image Path',
  72. 'is_publication' => 'Is Publication',
  73. 'is_recommend' => 'Is Recommend',
  74. 'is_top' => 'Is Top',
  75. 'link_url' => 'Link Url',
  76. 'meta_description' => 'Meta Description',
  77. 'meta_keywords' => 'Meta Keywords',
  78. 'min_content' => 'Min Content',
  79. 'sub_title' => 'Sub Title',
  80. 'title' => 'Title',
  81. 'up' => 'Up',
  82. 'article_category_id' => 'Article Category ID',
  83. 'createdatea' => 'Createdatea',
  84. 'modifydatea' => 'Modifydatea',
  85. 'meta_imge' => 'Meta Imge',
  86. 'sub_title1' => 'Sub Title1',
  87. 'title1' => 'Title1',
  88. 'author1' => 'Author1',
  89. 'content1' => 'Content1',
  90. 'min_content1' => 'Min_content1',
  91. 'sub_title2' => 'Sub_title2',
  92. 'title2' => 'Title2',
  93. 'author2' => 'Author2',
  94. 'content2' => 'Content2',
  95. 'min_content2' => 'Min_content2',
  96. ];
  97. }
  98. // 关联
  99. public function getCategory()
  100. {
  101. return $this->hasOne(ArticleCategory::className(), ['id' => 'article_category_id']);
  102. }
  103. }