<?php

namespace domain\Ticket\TicketUser;

use domain\Ticket\Ticket\Ticket;
use domain\User\User\User;
use domain\_\AbstractRepositoryQuery;

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;
    }
}