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.

WorkGroupChatDao.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\dao\work;
  3. use app\dao\BaseDao;
  4. use app\model\work\WorkGroupChat;
  5. use crmeb\traits\SearchDaoTrait;
  6. /**
  7. * 企业微信群
  8. * Class WorkGroupChatDao
  9. * @package app\dao\work
  10. */
  11. class WorkGroupChatDao extends BaseDao
  12. {
  13. use SearchDaoTrait;
  14. /**
  15. * @return string
  16. */
  17. protected function setModel(): string
  18. {
  19. return WorkGroupChat::class;
  20. }
  21. /**
  22. * @param array $where
  23. */
  24. public function groupChat(array $where)
  25. {
  26. return $this->getModel()->when(!empty($where['chat_id']), function ($query) use ($where) {
  27. $query->whereIn('owner', function ($query) use ($where) {
  28. $query->name('work_group_msg_task')->when(!empty($where['status']), function ($query) use ($where) {
  29. $query->where('status', $where['status']);
  30. })->whereIn('chat_id', $where['chat_id'])->field('userid');
  31. });
  32. })->when(!empty($where['owner']), function ($query) use ($where) {
  33. $query->whereIn('owner', $where['owner']);
  34. })->when(!empty($where['name']), function ($query) use ($where) {
  35. $query->whereLike('name', '%' . $where['name'] . '%');
  36. })->when(!empty($where['chat_id']), function ($query) use ($where) {
  37. if (is_array($where['chat_id'])) {
  38. $query->whereIn('chat_id', $where['chat_id']);
  39. } else {
  40. $query->where('chat_id', $where['chat_id']);
  41. }
  42. });
  43. }
  44. }