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.

63 satır
1.6KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\Credit;
  3. use App\Entity\User\UserMerchant;
  4. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  5. use Lc\CaracoleBundle\Repository\AbstractStore;
  6. use DateTime;
  7. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  8. class CreditHistoryStore extends AbstractStore
  9. {
  10. use MerchantStoreTrait;
  11. protected CreditHistoryRepositoryQuery $query;
  12. public function __construct(CreditHistoryRepositoryQuery $query)
  13. {
  14. $this->query = $query;
  15. }
  16. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  17. {
  18. $query->orderBy('createdAt');
  19. return $query;
  20. }
  21. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  22. {
  23. $query->filterByMerchant($this->merchant);
  24. return $query;
  25. }
  26. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  27. {
  28. return $query;
  29. }
  30. //findAllByDateStartEnd
  31. public function getByDateStartEnd(DateTime $dateStart, DateTime $dateEnd, $query = null): array
  32. {
  33. $query = $this->createDefaultQuery($query);
  34. $query
  35. ->filterByDateStart($dateStart)
  36. ->filterByDateEnd($dateEnd);
  37. return $query->find();
  38. }
  39. //findAllByUserMerchant
  40. public function getByUserMerchant(UserMerchant $userMerchant, $query = null): array
  41. {
  42. $query = $this->createDefaultQuery($query);
  43. $query
  44. ->filterByUserMerchant($userMerchant)
  45. ->orderBy('createdAt', 'DESC');
  46. return $query->find();
  47. }
  48. }