WorkWelcomeDao.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\dao\work;
  12. use app\dao\BaseDao;
  13. use app\model\work\WorkWelcome;
  14. use crmeb\basic\BaseAuth;
  15. use crmeb\traits\SearchDaoTrait;
  16. /**
  17. * Class WorkWelcomeDao
  18. * @package app\dao\wechat\work
  19. */
  20. class WorkWelcomeDao extends BaseDao
  21. {
  22. use SearchDaoTrait;
  23. /**
  24. * @return string
  25. */
  26. protected function setModel(): string
  27. {
  28. return WorkWelcome::class;
  29. }
  30. /**
  31. * 搜索
  32. * @param array $where
  33. * @param bool $authWhere
  34. * @return \crmeb\basic\BaseModel
  35. */
  36. public function searchWhere(array $where, bool $authWhere = true)
  37. {
  38. [$with] = app()->make(BaseAuth::class)->________(array_keys($where), $this->setModel());
  39. return $this->getModel()->withSearch($with, $where)->when(!empty($where['userids']), function ($query) use ($where) {
  40. $query->whereIn('id', function ($query) use ($where) {
  41. $query->name('wechat_work_welcome_relation')->whereIn('userid', $where['userids'])->field(['welcome_id']);
  42. });
  43. })->when(!empty($where['id']), function ($query) use ($where) {
  44. if (is_array($where['id'])) {
  45. $query->whereIn('id', $where['id']);
  46. } else {
  47. $query->where('id', $where['id']);
  48. }
  49. });
  50. }
  51. }