|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Credit;
-
- use App\Entity\Merchant\Merchant;
- use App\Entity\User\UserMerchant;
- use Knp\Component\Pager\PaginatorInterface;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
- use Lc\SovBundle\Repository\AbstractRepositoryQuery;
- use DateTime;
-
- class CreditHistoryRepositoryQuery extends AbstractRepositoryQuery
- {
- protected $isJoinUserMerchants = false;
-
- public function __construct(CreditHistoryRepository $repository, PaginatorInterface $paginator)
- {
- parent::__construct($repository, 'r', $paginator);
- }
-
- public function joinUserMerchant(): self
- {
- if (!$this->isJoinUserMerchants) {
- $this->isJoinUserMerchants = true;
-
- return $this
- ->innerJoin('.userMerchant', 'um');
- }
- return $this;
- }
-
- public function filterByMerchant(MerchantInterface $merchant): self
- {
- $this->joinUserMerchant();
- return $this
- ->andWhereMerchant('um', $merchant);
- }
-
- public function filterByUserMerchant(UserMerchantInterface $userMerchant): self
- {
- return $this
- ->andWhere('.userMerchant = :userMerchant')
- ->setParameter('userMerchant', $userMerchant);
- }
-
- public function filterByDateStart(DateTime $dateStart): self
- {
- return $this
- ->andWhere('.createdAt >= :dateStart')
- ->setParameter(':dateStart', $dateStart);
- }
-
- public function filterByDateEnd(DateTime $dateEnd): self
- {
- return $this
- ->andWhere('.createdAt <= :dateEnd')
- ->setParameter(':dateEnd', $dateEnd);
- }
- }
|