<?php

namespace domain\Order\ProductOrder;

use domain\Order\Order\Order;
use domain\_\AbstractRepository;

class ProductOrderRepository extends AbstractRepository
{
    protected ProductOrderRepositoryQuery $query;

    public function loadDependencies(): void
    {
        $this->loadQuery(ProductOrderRepositoryQuery::class);
    }

    public function getDefaultOptionsSearch(): array
    {
        return [
            self::WITH => ['taxRate'],
            self::JOIN_WITH => [],
            self::ORDER_BY => '',
            self::ATTRIBUTE_ID_PRODUCER => ''
        ];
    }

    public function findOneProductOrderById(int $id)
    {
        return $this->createDefaultQuery()
            ->filterById($id)
            ->findOne();
    }

    public function findProductOrdersByOrder(Order $order): array
    {
        return $this->createDefaultQuery()
            ->filterByOrder($order)
            ->find();
    }
}