|
- <?php
-
- namespace Lc\SovBundle\Repository\Ticket;
-
- use App\Entity\Ticket\Ticket;
- use Lc\SovBundle\Model\Ticket\TicketInterface;
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Repository\AbstractStore;
-
- class TicketStore extends AbstractStore implements TicketStoreInterface
- {
- protected TicketRepositoryQueryInterface $query;
-
- public function __construct(TicketRepositoryQueryInterface $query)
- {
- $this->query = $query;
- }
-
- // getTicketsByUser
- public function getByUser(UserInterface $user, $query = null): array
- {
- $query = $this->createQuery($query);
- $query->filterByUser($user);
- return $query->find();
- }
-
- // findAllOpen
- public function getOpen(int $limit = 0, $query = null): array
- {
- $query = $this->createQuery($query);
-
- $query
- ->filterByStatus(Ticket::TICKET_STATUS_OPEN)
- ->limit($limit)
- ->orderBy('r.id', 'DESC');
-
- return $query->find();
- }
-
- // countAllOpen
- public function countOpen($query = null): string
- {
- $query = $this->createQuery($query);
-
- $query
- ->selectCount()
- ->filterByStatus(Ticket::TICKET_STATUS_OPEN);
-
- return $query->count();
- }
- }
|