<?php

namespace common\logic\Distribution\ProductDistribution\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\ProductDistribution\Model\ProductDistribution;
use common\logic\Distribution\ProductDistribution\Service\ProductDistributionDefinition;
use common\logic\Product\Product\Model\Product;
use yii\db\ActiveQuery;

class ProductDistributionRepositoryQuery extends AbstractRepositoryQuery
{
    protected ProductDistributionDefinition $definition;

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

    public function filterByDistribution(Distribution $distribution): self
    {
        $this->andWhere(['id_distribution' => $distribution->id]);

        return $this;
    }

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

        return $this;
    }
}