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.

58 lines
1.5KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Reduction;
  3. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  4. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
  5. use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
  6. use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
  7. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  8. use Lc\SovBundle\Model\User\UserInterface;
  9. use Lc\SovBundle\Repository\AbstractStore;
  10. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  11. class ReductionCreditStore extends AbstractStore
  12. {
  13. use SectionStoreTrait;
  14. protected ReductionCreditRepositoryQuery $query;
  15. public function __construct(
  16. ReductionCreditRepositoryQuery $query
  17. ) {
  18. $this->query = $query;
  19. }
  20. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  21. {
  22. $query->orderBy('id');
  23. return $query;
  24. }
  25. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  26. {
  27. $query->filterBySection($this->section);
  28. $query->filterIsOnlineAndOffline();
  29. return $query;
  30. }
  31. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  32. {
  33. return $query;
  34. }
  35. // findReductionCreditsByUser
  36. public function getByTypeAndUser(string $type, UserInterface $user, $query = null)
  37. {
  38. $query = $this->createDefaultQuery($query);
  39. $query
  40. ->filterByType($type)
  41. ->filterByUser($user);
  42. return $query->find();
  43. }
  44. }