|
- <?php
-
- namespace common\logic\Payment\Repository;
-
- use common\logic\AbstractRepository;
- use common\logic\Order\Order\Model\Order;
- use common\logic\Payment\Model\Payment;
- use common\logic\User\User\Model\User;
-
- 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();
- }
- }
|