ArticleCollect.php 582 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class ArticleCollect extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'userid' => 'int',
  10. 'articleid' => 'int',
  11. 'createtime' => 'int'
  12. ];
  13. // 设置字段自动转换类型
  14. protected $type = [
  15. 'createtime' => 'timestamp:Y-m-d H:i:s'
  16. ];
  17. // 关联Article
  18. public function article()
  19. {
  20. return $this->hasOne(Article::class, "id", "articleid");
  21. }
  22. // 关联User
  23. public function user()
  24. {
  25. return $this->hasOne(User::class, "id", "userid");
  26. }
  27. }