Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ReductionCreditRepositoryQuery.php 1.6KB

pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Knp\Component\Pager\PaginatorInterface;
  4. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
  5. use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
  6. use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
  7. use Lc\SovBundle\Model\User\UserInterface;
  8. use Lc\SovBundle\Repository\AbstractRepositoryQuery;
  9. class ReductionCreditRepositoryQuery extends AbstractRepositoryQuery
  10. {
  11. use SectionRepositoryQueryTrait;
  12. protected $isJoinUsers = false;
  13. public function __construct(ReductionCreditRepository $repository, PaginatorInterface $paginator)
  14. {
  15. parent::__construct($repository, 'reductionCredit', $paginator);
  16. }
  17. public function filterByUser(UserInterface $user)
  18. {
  19. return $this
  20. ->andWhere(':user MEMBER OF .users')
  21. ->setParameter('user', $user);
  22. }
  23. public function filterByOwner(UserInterface $user)
  24. {
  25. return $this
  26. ->andWhere('.owner = :user')
  27. ->setParameter('user', $user);
  28. }
  29. public function filterByType(string $type = ReductionCreditModel::TYPE_CREDIT)
  30. {
  31. return $this
  32. ->andWhere('.type = :type')
  33. ->setParameter('type', $type);
  34. }
  35. public function filterInactive()
  36. {
  37. $this->joinUsers();
  38. return $this->having('COUNT(users.id) = 0');
  39. }
  40. public function filterActive()
  41. {
  42. $this->joinUsers();
  43. return $this->having('COUNT(users.id) > 0');
  44. }
  45. public function joinUsers()
  46. {
  47. return $this->leftJoin('.users', 'users');
  48. }
  49. }