選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

CreditHistoryRepositoryQuery.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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, 'creditHistory', $paginator);
  16. }
  17. public function joinUserMerchant(): self
  18. {
  19. if (!$this->isJoinUserMerchants) {
  20. $this->isJoinUserMerchants = true;
  21. return $this
  22. ->innerJoin('.userMerchant', 'userMerchant');
  23. }
  24. return $this;
  25. }
  26. public function filterByMerchant(MerchantInterface $merchant): self
  27. {
  28. $this->joinUserMerchant();
  29. return $this
  30. ->andWhereMerchant('userMerchant', $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. }