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.

61 linhas
1.7KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Credit;
  3. use App\Entity\Merchant\Merchant;
  4. use App\Entity\User\UserMerchant;
  5. use Knp\Component\Pager\PaginatorInterface;
  6. use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
  7. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  8. use DateTime;
  9. class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery
  10. {
  11. protected $isJoinUserMerchants = false;
  12. public function __construct(CreditHistoryRepository $repository, PaginatorInterface $paginator)
  13. {
  14. parent::__construct($repository, 'r', $paginator);
  15. }
  16. public function joinUserMerchant(): self
  17. {
  18. if (!$this->isJoinUserMerchants) {
  19. $this->isJoinUserMerchants = true;
  20. return $this
  21. ->innerJoin('.userMerchant', 'um');
  22. }
  23. return $this;
  24. }
  25. public function filterByJoinUserMerchant(Merchant $merchant): self
  26. {
  27. $this->joinUserMerchant();
  28. return $this
  29. ->andWhere('um.merchant = :merchant')
  30. ->setParameter('merchant', $merchant);
  31. }
  32. public function filterByUserMerchant(UserMerchant $userMerchant): self
  33. {
  34. return $this
  35. ->andWhere('.userMerchant = :userMerchant')
  36. ->setParameter('userMerchant', $userMerchant);
  37. }
  38. public function filterByDateStart(DateTime $dateStart): self
  39. {
  40. return $this
  41. ->andWhere('.createdAt >= :dateStart')
  42. ->setParameter(':dateStart', $dateStart);
  43. }
  44. public function filterByDateEnd(DateTime $dateEnd): self
  45. {
  46. return $this
  47. ->andWhere('.createdAt <= :dateEnd')
  48. ->setParameter(':dateEnd', $dateEnd);
  49. }
  50. }