您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TicketRepositoryQuery.php 2.0KB

3 年前
3 年前
3 年前
3 年前
3 年前
3 年前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Lc\SovBundle\Repository\Ticket;
  3. use Knp\Component\Pager\PaginatorInterface;
  4. use Lc\SovBundle\Model\User\UserInterface;
  5. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  6. class TicketRepositoryQuery extends AbstractRepositoryQuery implements TicketRepositoryQueryInterface
  7. {
  8. protected $isJoinUser = false;
  9. public function __construct(TicketRepository $repository, PaginatorInterface $paginator)
  10. {
  11. parent::__construct($repository, 'ticket', $paginator);
  12. }
  13. public function filterByUser(UserInterface $user): self
  14. {
  15. return $this
  16. ->andWhere('.user = :user')
  17. ->setParameter('user', $user);
  18. }
  19. public function joinUser(): self
  20. {
  21. if (!$this->isJoinUser) {
  22. $this->isJoinUser = true;
  23. return $this
  24. ->leftJoin('.user', 'user');
  25. }
  26. return $this;
  27. }
  28. public function filterByStatus($statusArray): self
  29. {
  30. return $this
  31. ->andWhere('.status IN (:status)')
  32. ->setParameter('status', $statusArray);
  33. }
  34. public function filterByFirstname(string $firstname)
  35. {
  36. $this->joinUser();
  37. return $this
  38. ->andWhere('.visitorFirstname LIKE :firstname OR user.firstname LIKE :firstname')
  39. ->setParameter('firstname', $firstname);
  40. }
  41. public function filterByLastname(string $lastname)
  42. {
  43. $this->joinUser();
  44. return $this
  45. ->andWhere('.visitorLastname LIKE :lastname OR user.lastname LIKE :lastname')
  46. ->setParameter('lastname', $lastname);
  47. }
  48. public function filterByEmail(string $email)
  49. {
  50. $this->joinUser();
  51. return $this
  52. ->andWhere('.visitorEmail LIKE :email OR user.email LIKE :email')
  53. ->setParameter('email', $email);
  54. }
  55. public function selectCount(): self
  56. {
  57. return $this
  58. ->select('count(ticket.id) as count');
  59. }
  60. }