diff --git a/src/Entity/InvoiceRepository.php b/src/Entity/InvoiceRepository.php index cc3521e..825d0ef 100644 --- a/src/Entity/InvoiceRepository.php +++ b/src/Entity/InvoiceRepository.php @@ -5,10 +5,12 @@ namespace Baraja\Shop\Invoice\Entity; +use Baraja\EcommerceStandard\DTO\InvoiceInterface; use Baraja\EcommerceStandard\DTO\OrderInterface; +use Baraja\Shop\Order\Repository\OrderInvoiceRepository; use Doctrine\ORM\EntityRepository; -final class InvoiceRepository extends EntityRepository +final class InvoiceRepository extends EntityRepository implements OrderInvoiceRepository { /** * @return array @@ -25,4 +27,26 @@ public function getByOrder(OrderInterface $order): array return $invoices; } + + + /** + * @param array $ids + * @return array + */ + public function getInvoicesByOrderIds(array $ids): array + { + /** @var array $invoices */ + $invoices = $this->createQueryBuilder('i') + ->where('i.order IN (:ids)') + ->setParameter('ids', $ids) + ->getQuery() + ->getResult(); + + $return = []; + foreach ($invoices as $invoice) { + $return[$invoice->getOrder()->getId()] = $invoice; + } + + return $return; + } }