You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 line
1.1KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Knp\Component\Pager\PaginatorInterface;
  4. use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
  5. use Lc\SovBundle\Model\User\UserInterface;
  6. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  7. class ReductionCartRepositoryQuery extends AbstractRepositoryQuery
  8. {
  9. use MerchantRepositoryQueryTrait;
  10. public function __construct(ReductionCartRepository $repository, PaginatorInterface $paginator)
  11. {
  12. parent::__construct($repository, 'reductionCart', $paginator);
  13. }
  14. public function filterByCode(string $code)
  15. {
  16. return $this
  17. ->andWhere('.codes LIKE :code')
  18. ->setParameter('code', '%'.$code.'%') ;
  19. }
  20. public function filterByUser(UserInterface $user)
  21. {
  22. return $this
  23. ->andWhere(':user MEMBER OF .users')
  24. ->setParameter('user', $user);
  25. }
  26. public function filterByType(string $type, string $operator = '=')
  27. {
  28. return $this
  29. ->andWhere('.type '.$operator.' :type')
  30. ->setParameter('type', $type);
  31. }
  32. }