選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

TicketRepositoryQuery.php 2.2KB

3年前
3年前
3年前
3年前
3年前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. public function filterByVisitorToken(string $visitorToken): self
  61. {
  62. return $this
  63. ->andWhere('.visitorToken LIKE :visitorToken')
  64. ->setParameter('visitorToken', $visitorToken);
  65. }
  66. }