<?php

namespace Lc\SovBundle\Repository\Ticket;

use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class TicketMessageStore extends AbstractStore implements TicketMessageStoreInterface
{
    protected TicketMessageRepositoryQueryInterface $query;

    public function __construct(TicketMessageRepositoryQueryInterface $query)
    {
        $this->query = $query;
    }

    public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
    {
        $query->orderBy('createdAt', 'ASC');
        return $query;
    }

    public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
    {
        return $query;
    }

    public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
    {
        return $query;
    }

    public function getByTicket(TicketInterface $ticket, $query = null)
    {
        $query = $this->createDefaultQuery($query);
        $query->filterByTicket($ticket);
        return $query->find();
    }
}
