Notice.php 737 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace addons\qingdongams\model;
  3. use think\Model;
  4. use traits\model\SoftDelete;
  5. /**
  6. *公告表
  7. */
  8. class Notice Extends Model {
  9. use SoftDelete;
  10. // 表名,不含前缀
  11. protected $name = 'qingdongams_notice';
  12. // 开启自动写入时间戳字段
  13. protected $autoWriteTimestamp = 'int';
  14. // 定义时间戳字段名
  15. protected $createTime = 'createtime';
  16. protected $updateTime = 'updatetime';
  17. protected $deleteTime = 'deletetime';
  18. //获取创建时间
  19. public function getCreatetimeAttr($value) {
  20. return date('Y-m-d H:i:s', $value);
  21. }
  22. public function read(){
  23. return $this->hasMany(NoticeRead::class, 'notice_id', 'id')->field('notice_id,staff_id,createtime');
  24. }
  25. }