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.

35 line
949B

  1. <?php
  2. namespace domain\Payment;
  3. use domain\Order\Order\Order;
  4. use domain\User\User\User;
  5. use domain\_\AbstractRepositoryQuery;
  6. class PaymentRepositoryQuery extends AbstractRepositoryQuery
  7. {
  8. protected PaymentDefinition $definition;
  9. public function loadDependencies(): void
  10. {
  11. $this->loadDefinition(PaymentDefinition::class);
  12. }
  13. public function filterByOrder(Order $order): self
  14. {
  15. $this->andWhere(['id_order' => $order->id]);
  16. return $this;
  17. }
  18. public function filterByUser(User $user): self
  19. {
  20. $this->andWhere(['id_user' => $user->id]);
  21. return $this;
  22. }
  23. public function filterIsCredit()
  24. {
  25. $this->andWhere("payment.type = 'initial-credit' OR payment.type = 'credit' OR payment.type = 'debit' OR (payment.type = 'payment' AND payment.mean_payment = 'credit') OR (payment.type = 'refund' AND payment.mean_payment = 'credit')");
  26. return $this;
  27. }
  28. }