Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CreditHistoryRepositoryQuery.php 1.6KB

před 3 roky
před 3 roky
před 3 roky
před 3 roky
před 3 roky
před 3 roky
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\SovBundle\Repository\AbstractRepositoryQuery;
  7. use DateTime;
  8. class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery
  9. {
  10. protected $isJoinUserMerchants = false;
  11. public function __construct(CreditHistoryRepository $repository, PaginatorInterface $paginator)
  12. {
  13. parent::__construct($repository, 'r', $paginator);
  14. }
  15. public function joinUserMerchant(): self
  16. {
  17. if (!$this->isJoinUserMerchants) {
  18. $this->isJoinUserMerchants = true;
  19. return $this
  20. ->innerJoin('.userMerchant', 'um');
  21. }
  22. return $this;
  23. }
  24. public function filterByJoinUserMerchant(Merchant $merchant): self
  25. {
  26. $this->joinUserMerchant();
  27. return $this
  28. ->andWhere('um.merchant = :merchant')
  29. ->setParameter('merchant', $merchant);
  30. }
  31. public function filterByUserMerchant(UserMerchant $userMerchant): self
  32. {
  33. return $this
  34. ->andWhere('.userMerchant = :userMerchant')
  35. ->setParameter('userMerchant', $userMerchant);
  36. }
  37. public function filterByDateStart(DateTime $dateStart): self
  38. {
  39. return $this
  40. ->andWhere('.createdAt >= :dateStart')
  41. ->setParameter(':dateStart', $dateStart);
  42. }
  43. public function filterByDateEnd(DateTime $dateEnd): self
  44. {
  45. return $this
  46. ->andWhere('.createdAt <= :dateEnd')
  47. ->setParameter(':dateEnd', $dateEnd);
  48. }
  49. }