|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
-
- namespace domain\Payment;
-
- use domain\Order\Order\Order;
- use domain\User\User\User;
- use domain\_\AbstractRepository;
-
- class PaymentRepository extends AbstractRepository
- {
- protected PaymentRepositoryQuery $query;
-
- public function loadDependencies(): void
- {
- $this->loadQuery(PaymentRepositoryQuery::class);
- }
-
- public function getDefaultOptionsSearch(): array
- {
- return [
- self::WITH => [
- 'user',
- 'order',
- 'userAction'
- ],
- self::JOIN_WITH => [],
- self::ORDER_BY => Payment::tableName() . '.date ASc',
- self::ATTRIBUTE_ID_PRODUCER => Payment::tableName() . '.id_producer'
- ];
- }
-
- public function getByOrder(Order $order)
- {
- return $this->createDefaultQuery()
- ->filterByOrder($order)
- ->find();
- }
-
- public function queryPaymentsCreditHistoryByUser(User $user)
- {
- return $this->createDefaultQuery()
- ->filterByUser($user)
- ->filterIsCredit()
- ->orderBy('date DESC');
- }
-
- public function findPaymentsCreditHistoryByUser(User $user): array
- {
- return $this->queryPaymentsCreditHistoryByUser($user)->find();
- }
- }
|