Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

90 lines
2.3KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  4. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  5. use Lc\SovBundle\Model\User\UserInterface;
  6. use Lc\CaracoleBundle\Repository\AbstractStore;
  7. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  8. class ReductionCreditStore extends AbstractStore
  9. {
  10. use SectionStoreTrait;
  11. use MerchantStoreTrait;
  12. protected ReductionCreditRepositoryQuery $query;
  13. public function __construct(
  14. ReductionCreditRepositoryQuery $query
  15. ) {
  16. $this->query = $query;
  17. }
  18. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  19. {
  20. $query->orderBy('id');
  21. return $query;
  22. }
  23. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  24. {
  25. $this->addFilterBySectionOptionnal($query);
  26. $this->addFilterByMerchantViaSectionOptionnal($query);
  27. $query->filterIsOnlineAndOffline();
  28. return $query;
  29. }
  30. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  31. {
  32. return $query;
  33. }
  34. // findReductionCreditsByUser
  35. public function getByTypeAndUser(string $type, UserInterface $user, $query = null)
  36. {
  37. $query = $this->createDefaultQuery($query);
  38. $query
  39. ->filterByType($type)
  40. ->filterByUser($user);
  41. return $query->find();
  42. }
  43. // findReductionGiftToUseByUser
  44. public function getReductionGiftToUseByUser(UserInterface $user, $query = null)
  45. {
  46. $query = $this->createDefaultQuery($query);
  47. $query->filterByUser($user);
  48. return $query->find();
  49. }
  50. // findReductionGiftOwnedByUser
  51. public function getReductionGiftOwnedByUser(UserInterface $user, $query = null)
  52. {
  53. $query = $this->createDefaultQuery($query);
  54. $query
  55. ->filterByOwner($user)
  56. ->filterInactive();
  57. return $query->find();
  58. }
  59. // findReductionGiftOwnedActiveByUser
  60. public function getReductionGiftOwnedActiveByUser(UserInterface $user, $query = null)
  61. {
  62. $query = $this->createDefaultQuery($query);
  63. $query
  64. ->filterByOwner($user)
  65. ->filterActive();
  66. return $query->find();
  67. }
  68. }