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

UserRepositoryQuery.php 1.9KB

3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Lc\SovBundle\Repository\User;
  3. use App\Entity\Merchant\Merchant;
  4. use App\Entity\Newsletter\Newsletter;
  5. use Knp\Component\Pager\PaginatorInterface;
  6. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  7. class UserRepositoryQuery extends AbstractRepositoryQuery implements UserRepositoryQueryInterface
  8. {
  9. public function __construct(UserRepository $repository, PaginatorInterface $paginator)
  10. {
  11. parent::__construct($repository, 'user', $paginator);
  12. }
  13. protected $isJoinGroupUsers = false;
  14. public function joinGroupUsers($addSelect = true): self
  15. {
  16. if (!$this->isJoinGroupUsers) {
  17. $this->isJoinGroupUsers = true;
  18. $this->leftJoin('.groupUsers', 'groupUsers');
  19. if($addSelect){
  20. $this->addSelect('groupUsers');
  21. }
  22. }
  23. return $this;
  24. }
  25. public function filterByNewsletter(Newsletter $newsletter): self
  26. {
  27. return $this
  28. ->andWhere(':newsletter MEMBER OF .newsletters')
  29. ->setParameter('newsletter', $newsletter->getId());
  30. }
  31. public function filterByRole(string $role): self
  32. {
  33. return $this
  34. ->andWhere('.roles LIKE :roles')
  35. ->setParameter('roles', '%"' . $role . '"%');
  36. }
  37. public function filterByTicketTypeNotification(string $ticketType): self
  38. {
  39. return $this
  40. ->andWhere('.ticketTypesNotification LIKE :ticketType')
  41. ->setParameter('ticketType', '%"' . $ticketType . '"%');
  42. }
  43. public function filterByEmail(string $email): self
  44. {
  45. return $this
  46. ->andWhere('.email LIKE :email')
  47. ->setParameter('email', $email);
  48. }
  49. public function filterByTerm(string $term): self
  50. {
  51. return $this
  52. ->andWhere('.email LIKE :term OR .firstname LIKE :term OR .lastname LIKE :term')
  53. ->setParameter('term', '%'.$term.'%');
  54. }
  55. }