EvectionInfo.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\common\model;
  3. use app\common\constant\CommonConstant;
  4. use think\Model;
  5. /**
  6. * 出差申请模型
  7. */
  8. class EvectionInfo extends Model
  9. {
  10. // 表名
  11. protected $name = 'evection_info';
  12. // 追加属性
  13. protected $append = [
  14. 'document_text',
  15. 'images_text',
  16. ];
  17. public function getDocumentTextAttr($value, $data)
  18. {
  19. $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
  20. return $value ? explode(',', $value) : [];
  21. }
  22. public function getImagesTextAttr($value, $data)
  23. {
  24. $value = $value ? $value : (isset($data['images']) ? $data['images'] : '');
  25. return $value ? explode(',', $value) : [];
  26. }
  27. // 关联出差同行人员
  28. public function peerUser()
  29. {
  30. return $this->hasMany(EvectionPeerUser::class, 'info_id', 'id');
  31. }
  32. // 关联出差审批
  33. public function approve()
  34. {
  35. return $this->hasMany(EvectionApprove::class, 'info_id', 'id')->where('is_deleted',CommonConstant::IS_DELETED_0);
  36. }
  37. // 关联出差审批
  38. public function approveInfo()
  39. {
  40. return $this->hasOne(EvectionApprove::class, 'info_id', 'id')->where('is_deleted',CommonConstant::IS_DELETED_0)->where('approve_type', CommonConstant::TYPE_1);
  41. }
  42. }