<?php

namespace common\logic\Document\Quotation\Repository;

use common\logic\AbstractRepository;
use common\logic\Document\Quotation\Model\Quotation;

class QuotationRepository extends AbstractRepository
{
    protected QuotationRepositoryQuery $query;

    public function loadDependencies(): void
    {
        $this->query = $this->loadService(QuotationRepositoryQuery::class);
    }

    public function getDefaultOptionsSearch(): array
    {
        return [
            'with' => [],
            'join_with' => ['user AS user_quotation', 'producer'],
            'orderby' => 'date ASC',
            'attribute_id_producer' => 'quotation.id_producer'
        ];
    }

    public function findOneQuotationById(int $id): ?Quotation
    {
        return Quotation::searchOne(['id' => $id]);
    }
}