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.

WorkMemberDao.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\dao\work;
  3. use app\dao\BaseDao;
  4. use app\model\work\WorkMember;
  5. use crmeb\basic\BaseAuth;
  6. use crmeb\traits\SearchDaoTrait;
  7. /**
  8. * 企业微信成员
  9. * Class WorkMemberDao
  10. * @package app\dao\work
  11. */
  12. class WorkMemberDao extends BaseDao
  13. {
  14. use SearchDaoTrait;
  15. /**
  16. * @return string
  17. */
  18. protected function setModel(): string
  19. {
  20. return WorkMember::class;
  21. }
  22. /**
  23. * 搜索
  24. * @param array $where
  25. * @param bool $authWhere
  26. */
  27. public function searchWhere(array $where, bool $authWhere = true)
  28. {
  29. [$with] = app()->make(BaseAuth::class)->________(array_keys($where), $this->setModel());
  30. return $this->getModel()->withSearch($with, $where)
  31. ->when(!empty($where['name']), function ($query) use ($where) {
  32. $query->where('id|name|mobile', 'like', '%' . $where['name'] . '%');
  33. })->when(!empty($where['department']), function ($query) use ($where) {
  34. $query->whereIn('id', function ($query) use ($where) {
  35. $query->name('work_member_relation')->where('department', $where['department'])->field(['member_id']);
  36. });
  37. });
  38. }
  39. }