Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

62 rindas
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\Model\Merchant\MerchantInterface;
  7. use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
  8. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  9. use DateTime;
  10. class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery
  11. {
  12. protected $isJoinUserMerchants = false;
  13. public function __construct(CreditHistoryRepository $repository, PaginatorInterface $paginator)
  14. {
  15. parent::__construct($repository, 'r', $paginator);
  16. }
  17. public function joinUserMerchant(): self
  18. {
  19. if (!$this->isJoinUserMerchants) {
  20. $this->isJoinUserMerchants = true;
  21. return $this
  22. ->innerJoin('.userMerchant', 'um');
  23. }
  24. return $this;
  25. }
  26. public function filterByMerchant(MerchantInterface $merchant): self
  27. {
  28. $this->joinUserMerchant();
  29. return $this
  30. ->andWhereMerchant('um', $merchant);
  31. }
  32. public function filterByUserMerchant(UserMerchantInterface $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. }