You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WorkDepartment.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace app\model\work;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. /**
  6. * 企业微信部门
  7. * Class WorkDepartment
  8. * @package app\model\work
  9. */
  10. class WorkDepartment extends BaseModel
  11. {
  12. use ModelTrait;
  13. /**
  14. * @var string
  15. */
  16. protected $name = 'work_department';
  17. /**
  18. * @var string
  19. */
  20. protected $key = 'id';
  21. /**
  22. * @var string
  23. */
  24. protected $autoWriteTimestamp = 'int';
  25. /**
  26. * 远程关联成员
  27. * @return \think\model\relation\HasManyThrough
  28. */
  29. public function member()
  30. {
  31. return $this->hasManyThrough(
  32. WorkMember::class,
  33. WorkMemberRelation::class, 'department', 'id', 'department_id', 'member_id');
  34. }
  35. /**
  36. * @param $query
  37. * @param $value
  38. */
  39. public function searchMobileAttr($query, $value)
  40. {
  41. if (is_array($value)) {
  42. $query->whereIn('mobile', $value);
  43. } else {
  44. $query->where('mobile', $value);
  45. }
  46. }
  47. /**
  48. * 企业微信id搜索
  49. * @param $query
  50. * @param $value
  51. */
  52. public function searchCorpIdAttr($query, $value)
  53. {
  54. $query->where('corp_id', $value);
  55. }
  56. /**
  57. * @param $query
  58. * @param $value
  59. */
  60. public function searchDepartmentIdAttr($query, $value)
  61. {
  62. if ('' !== $value) {
  63. $query->where('department_id', $value);
  64. }
  65. }
  66. }