<?php

namespace common\logic\Ticket\TicketUser\Repository;

use common\logic\AbstractRepositoryQuery;
use common\logic\Ticket\Ticket\Model\Ticket;
use common\logic\Ticket\TicketUser\Service\TicketUserDefinition;
use common\logic\User\User\Model\User;

class TicketUserRepositoryQuery extends AbstractRepositoryQuery
{
    protected TicketUserDefinition $definition;

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

    public function filterByTicket(Ticket $ticket): self
    {
        $this->andWhere(['ticket_user.id_ticket' => $ticket->id]);
        return $this;
    }

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