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.

52 lines
1.3KB

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