|
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Credit;
-
- use App\Entity\Merchant\Merchant;
- use App\Entity\User\UserMerchant;
- use Knp\Component\Pager\PaginatorInterface;
- use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
- 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 filterByJoinUserMerchant(Merchant $merchant): self
- {
- $this->joinUserMerchant();
- return $this
- ->andWhere('um.merchant = :merchant')
- ->setParameter('merchant', $merchant);
- }
-
- public function filterByUserMerchant(UserMerchant $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);
- }
- }
|