<?php

namespace domain\Product\Accessory;

use domain\_\AbstractRepository;
use domain\_\RepositoryQueryInterface;
use yii\db\ActiveQuery;

class AccessoryRepository extends AbstractRepository
{
    protected AccessoryRepositoryQuery $query;

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

    public function getDefaultOptionsSearch(): array
    {
        return [
            self::WITH => [],
            self::JOIN_WITH => [],
            self::ORDER_BY => 'accessory.name ASC',
            self::ATTRIBUTE_ID_PRODUCER => 'accessory.id_producer'
        ];
    }

    public function queryAccessories(): RepositoryQueryInterface
    {
        return $this->createDefaultQuery();
    }

    public function findOneAccessoryById(int $id): ?Accessory
    {
        return $this->createDefaultQuery()
            ->filterById($id)
            ->findOne();
    }
}