Comment.php 973 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace addons\qingdong\model;
  3. use think\Model;
  4. use traits\model\SoftDelete;
  5. /**
  6. *评论表
  7. */
  8. class Comment Extends Model {
  9. use SoftDelete;
  10. const DAILY_TYPE = 5;//工作报告
  11. // 表名,不含前缀
  12. protected $name = 'qingdong_comment';
  13. // 开启自动写入时间戳字段
  14. protected $autoWriteTimestamp = 'int';
  15. // 定义时间戳字段名
  16. protected $createTime = 'createtime';
  17. protected $updateTime = 'updatetime';
  18. protected $deleteTime = 'deletetime';
  19. public function staff() {
  20. return $this->belongsTo(Staff::class, 'staff_id', 'id')->field('id,name,img,post');
  21. }
  22. public function getCreatetimeAttr($value) {
  23. return date('Y-m-d H:i', $value);
  24. }
  25. //跟进
  26. public function record() {
  27. return $this->hasOne(Record::class, 'id', 'relation_id')->field('id,content');
  28. }
  29. //工作报告
  30. public function daily() {
  31. return $this->hasOne(Daily::class, 'id', 'relation_id')->field('id,type');
  32. }
  33. }