|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
-
- namespace Lc\CaracoleBundle\Repository\Reduction;
-
- use Knp\Component\Pager\PaginatorInterface;
- use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
- use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Repository\AbstractRepositoryQuery;
-
- class ReductionCreditRepositoryQuery extends AbstractRepositoryQuery
- {
- use MerchantRepositoryQueryTrait;
-
-
- protected $isJoinUsers = false;
-
- public function __construct(ReductionCreditRepository $repository, PaginatorInterface $paginator)
- {
- parent::__construct($repository, 'reductionCredit', $paginator);
- }
-
- public function filterByUser(UserInterface $user)
- {
- return $this
- ->andWhere(':user MEMBER OF .users')
- ->setParameter('user', $user);
- }
-
- public function filterByOwner(UserInterface $user)
- {
- return $this
- ->andWhere('.owner = :user')
- ->setParameter('user', $user);
- }
-
- public function filterByType(string $type = ReductionCreditModel::TYPE_CREDIT)
- {
- return $this
- ->andWhere('.type = :type')
- ->setParameter('type', $type);
- }
-
- public function filterInactive()
- {
- $this->joinUsers();
- return $this->andWhere('.users IS EMPTY');
- }
-
- public function filterActive()
- {
- $this->joinUsers();
- return $this->andWhere('.users IS NOT EMPTY');
- }
-
- public function joinUsers()
- {
- return $this->leftJoin('.users', 'users');
- }
- }
|