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.

73 lines
1.7KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\User;
  3. use Knp\Component\Pager\PaginatorInterface;
  4. use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
  5. use Lc\SovBundle\Model\User\UserInterface;
  6. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  7. class UserMerchantRepositoryQuery extends AbstractRepositoryQuery
  8. {
  9. use MerchantRepositoryQueryTrait;
  10. protected $isJoinUser = false;
  11. public function __construct(UserMerchantRepository $repository, PaginatorInterface $paginator)
  12. {
  13. parent::__construct($repository, 'userMerchant', $paginator);
  14. }
  15. public function filterByUser(UserInterface $user)
  16. {
  17. return $this
  18. ->andWhere('.user = :user')
  19. ->setParameter('user', $user);
  20. }
  21. public function joinUser(): self
  22. {
  23. if (!$this->isJoinUser) {
  24. $this->isJoinUser = true;
  25. return $this
  26. ->leftJoin('.user', 'user');
  27. }
  28. return $this;
  29. }
  30. public function filterByFirstname(string $firstname)
  31. {
  32. $this->joinUser();
  33. return $this
  34. ->andWhere('user.firstname LIKE :firstname')
  35. ->setParameter('firstname', $firstname);
  36. }
  37. public function filterByLastname(string $lastname)
  38. {
  39. $this->joinUser();
  40. return $this
  41. ->andWhere('user.lastname LIKE :lastname')
  42. ->setParameter('lastname', $lastname);
  43. }
  44. public function filterByEmail(string $email)
  45. {
  46. $this->joinUser();
  47. return $this
  48. ->andWhere('user.email LIKE :email')
  49. ->setParameter('email', $email);
  50. }
  51. public function filterIsCreditActive()
  52. {
  53. return $this
  54. ->andWhere('.creditActive = 1');
  55. }
  56. }