WorkClientFollow.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\work;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. use think\model\relation\HasMany;
  16. use think\model\relation\HasOne;
  17. /**
  18. * 企业微信客户跟踪
  19. * Class WorkClientFollow
  20. * @package app\model\work
  21. */
  22. class WorkClientFollow extends BaseModel
  23. {
  24. use ModelTrait;
  25. /**
  26. * @var string
  27. */
  28. protected $name = 'work_client_follow';
  29. /**
  30. * @var string
  31. */
  32. protected $key = 'id';
  33. /**
  34. * @var string
  35. */
  36. protected $autoWriteTimestamp = 'int';
  37. /**
  38. * @return HasOne
  39. */
  40. public function client()
  41. {
  42. return $this->hasOne(WorkClient::class, 'id', 'client_id');
  43. }
  44. /**
  45. * @return HasMany
  46. */
  47. public function tags()
  48. {
  49. return $this->hasMany(WorkClientFollowTags::class, 'follow_id', 'id');
  50. }
  51. /**
  52. * @return HasOne
  53. */
  54. public function member()
  55. {
  56. return $this->hasOne(WorkMember::class, 'userid', 'userid');
  57. }
  58. /**
  59. * @param $query
  60. * @param $value
  61. */
  62. public function searchClientIdAttr($query, $value)
  63. {
  64. if (is_array($value)) {
  65. $query->whereIn('client_id', $value);
  66. } else {
  67. $query->where('client_id', $value);
  68. }
  69. }
  70. /**
  71. * 是否删除搜索器
  72. * @param Model $query
  73. * @param $value
  74. * @param $data
  75. */
  76. public function searchIsDelUserAttr($query, $value)
  77. {
  78. if ($value !== '') $query->where('is_del_user', $value);
  79. }
  80. }