Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

UserMerchantRepositoryQuery.php 1.7KB

3 anos atrás
3 anos atrás
3 anos atrás
2 anos atrás
3 anos atrás
3 anos atrás
2 anos atrás
3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. }