<?php

namespace domain\Product\ProductAccessory;

use domain\_\AbstractRepositoryQuery;
use domain\Product\Accessory\Accessory;
use domain\Product\Product\Product;

class ProductAccessoryRepositoryQuery extends AbstractRepositoryQuery
{
    protected ProductAccessoryDefinition $definition;

    public function loadDependencies(): void
    {
        $this->loadDefinition(ProductAccessoryDefinition::class);
    }

    public function filterByProduct(Product $product): self
    {
        $this->andWhere(['product_accessory.id_product' => $product->id]);
        return $this;
    }

    public function filterByAccessory(Accessory $accessory): self
    {
        $this->andWhere(['product_accessory.id_accessory' => $accessory->id]);
        return $this;
    }
}