<?php

namespace common\logic\PointSale\PointSale\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\PointSale\PointSale\Service\PointSaleDefinition;
use common\logic\StatusInterface;
use yii\db\ActiveQuery;

class PointSaleRepositoryQuery extends AbstractRepositoryQuery
{
    protected PointSaleDefinition $definition;

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

    public function filterByIdUser(int $idUser): self
    {
        $this->andWhere(['id_user' => $idUser]);

        return $this;
    }

    public function filterByName(string $name): self
    {
        $this->andWhere(['name' => $name]);

        return $this;
    }

    public function filterIsOnline(): self
    {
        $this->andWhere(['status' => StatusInterface::STATUS_ONLINE]);

        return $this;
    }

    public function filterByRestrictedAccess(int $restrictedAccess): self
    {
        $this->andWhere(['restricted_access' => $restrictedAccess]);

        return $this;
    }
}