<?php

namespace domain\PointSale\UserPointSale;

use domain\PointSale\PointSale\PointSale;
use domain\User\User\User;
use domain\_\AbstractRepositoryQuery;

class UserPointSaleRepositoryQuery extends AbstractRepositoryQuery
{
    protected UserPointSaleDefinition $definition;

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

    public function joinPointSale(): self
    {
        $this->innerJoinWith('pointSale', true);
        return $this;
    }

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

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