WorkGroupMsgTaskDao.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\dao\work;
  3. use app\dao\BaseDao;
  4. use app\model\work\WorkGroupMsgTask;
  5. use crmeb\basic\BaseAuth;
  6. use crmeb\traits\SearchDaoTrait;
  7. /**
  8. * Class WorkGroupMsgTaskDao
  9. * @package app\dao\work
  10. */
  11. class WorkGroupMsgTaskDao extends BaseDao
  12. {
  13. use SearchDaoTrait;
  14. /**
  15. * @return string
  16. */
  17. protected function setModel(): string
  18. {
  19. return WorkGroupMsgTask::class;
  20. }
  21. /**
  22. * @param array $where
  23. * @param bool $authWhere
  24. * @return \crmeb\basic\BaseModel
  25. */
  26. public function searchWhere(array $where, bool $authWhere = true)
  27. {
  28. [$with, $whereKey] = app()->make(BaseAuth::class)->________(array_keys($where), $this->setModel());
  29. $whereData = [];
  30. foreach ($whereKey as $key) {
  31. if (isset($where[$key]) && 'timeKey' !== $key) {
  32. $whereData[$key] = $where[$key];
  33. }
  34. }
  35. return $this->getModel()->withSearch($with, $where)->when(!empty($where['user_name']), function ($query) use ($where) {
  36. $query->whereIn('userid', function ($query) use ($where) {
  37. $query->name('work_member')->where('name', 'like', '%' . $where['user_name'] . '%')->field(['userid']);
  38. });
  39. });
  40. }
  41. }