Attendance.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace addons\qingdongams\model;
  3. use think\Model;
  4. use traits\model\SoftDelete;
  5. /**
  6. *考勤管理
  7. */
  8. class Attendance Extends Model {
  9. use SoftDelete;
  10. // 表名,不含前缀
  11. protected $name = 'qingdongams_attendance';
  12. // 开启自动写入时间戳字段
  13. protected $autoWriteTimestamp = 'int';
  14. // 定义时间戳字段名
  15. protected $createTime = 'createtime';
  16. protected $updateTime = 'updatetime';
  17. protected $deleteTime = 'deletetime';
  18. // 追加属性
  19. protected $append = [
  20. 'files',
  21. ];
  22. //创建人
  23. public function createStaff() {
  24. return $this->hasOne(Staff::class, 'id', 'staff_id')->field('id,name,img,post');
  25. }
  26. //创建人
  27. public function staff() {
  28. return $this->hasOne(Staff::class, 'id', 'staff_id')->field('id,name,img,post');
  29. }
  30. /**
  31. * 获取
  32. */
  33. public function getFilesAttr($value, $data)
  34. {
  35. if (empty($data['file_ids'])) {
  36. return '';
  37. }
  38. $paths = File::where(['id' => ['in', $data['file_ids']]])->column('file_path');
  39. return $paths?implode(',', $paths):'';
  40. }
  41. }