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.

PaymentRepository.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace domain\Payment;
  3. use domain\Order\Order\Order;
  4. use domain\User\User\User;
  5. use domain\_\AbstractRepository;
  6. class PaymentRepository extends AbstractRepository
  7. {
  8. protected PaymentRepositoryQuery $query;
  9. public function loadDependencies(): void
  10. {
  11. $this->loadQuery(PaymentRepositoryQuery::class);
  12. }
  13. public function getDefaultOptionsSearch(): array
  14. {
  15. return [
  16. self::WITH => [
  17. 'user',
  18. 'order',
  19. 'userAction'
  20. ],
  21. self::JOIN_WITH => [],
  22. self::ORDER_BY => Payment::tableName() . '.date ASc',
  23. self::ATTRIBUTE_ID_PRODUCER => Payment::tableName() . '.id_producer'
  24. ];
  25. }
  26. public function getByOrder(Order $order)
  27. {
  28. return $this->createDefaultQuery()
  29. ->filterByOrder($order)
  30. ->find();
  31. }
  32. public function queryPaymentsCreditHistoryByUser(User $user)
  33. {
  34. return $this->createDefaultQuery()
  35. ->filterByUser($user)
  36. ->filterIsCredit()
  37. ->orderBy('date DESC');
  38. }
  39. public function findPaymentsCreditHistoryByUser(User $user): array
  40. {
  41. return $this->queryPaymentsCreditHistoryByUser($user)->find();
  42. }
  43. }