<?php

namespace common\logic\Document\DeliveryNote\Repository;

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

class DeliveryNoteRepository extends AbstractRepository
{
    protected DeliveryNoteRepositoryQuery $query;

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

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

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