DailyRead.php 744 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace addons\qingdongams\model;
  3. use think\Exception;
  4. use think\Model;
  5. /**
  6. *工作报告
  7. */
  8. class DailyRead Extends Model {
  9. // 表名,不含前缀
  10. protected $name = 'qingdongams_daily_read';
  11. // 开启自动写入时间戳字段
  12. protected $autoWriteTimestamp = 'int';
  13. // 定义时间戳字段名
  14. protected $createTime = 'createtime';
  15. protected $updateTime = 'updatetime';
  16. //添加阅读记录
  17. public static function addRead($daily_id, $staff_id) {
  18. return self::create(['daily_id' => $daily_id, 'staff_id' => $staff_id]);
  19. }
  20. //获取员工
  21. public function staff() {
  22. return $this->hasOne(Staff::class, 'id', 'staff_id')->field('id,name,img,department_id');
  23. }
  24. }