<?php

namespace common\logic\Product\ProductPrice\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Product\Product\Model\Product;
use common\logic\Product\ProductPrice\Model\ProductPrice;
use common\logic\Product\ProductPrice\Service\ProductPriceDefinition;
use common\logic\User\User\Model\User;
use common\logic\User\UserGroup\Model\UserGroup;
use yii\db\ActiveQuery;

class ProductPriceRepositoryQuery extends AbstractRepositoryQuery
{
    protected ProductPriceDefinition $definition;

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

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

    public function filterByUser(User $user): self
    {
        $this->andWhere(['id_user' => $user->id]);
        return $this;
    }

    public function filterByUserGroup(UserGroup $userGroup): self
    {
        $this->andWhere(['id_user_group' => $userGroup->id]);
        return $this;
    }

    public function filterByPointSale(PointSale $pointSale): self
    {
        $this->andWhere(['id_point_sale' => $pointSale->id]);
        return $this;
    }

    public function filterByFromQuantity(float $fromQuantity): self
    {
        $this->andWhere(['from_quantity' => $fromQuantity]);
        return $this;
    }
}