|
- <?php
-
- namespace Lc\SovBundle\Repository\Ticket;
-
- use App\Entity\Ticket\Ticket;
- use Lc\SovBundle\Model\Ticket\TicketInterface;
- 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($user, $query = null): array
- {
- if (is_null($query)) {
- $query = $this->query->create();
- }
-
- $query->filterByUser($user);
-
- return $query->find();
- }
-
- // findAllOpen
- public function getAllOpen(int $limit = 0, $query = null): array
- {
- if (is_null($query)) {
- $query = $this->query->create();
- }
-
- $query
- ->filterByStatus(Ticket::TICKET_STATUS_OPEN)
- ->limit($limit)
- ->orderBy('r.id', 'DESC');
-
- return $query->find();
- }
-
- // public function findAllOpen($limit = 0)
- // {
- // $query = $this->findByMerchantQuery();
- // $this->filterStatus($query, [Ticket::TICKET_STATUS_OPEN]);
- // $query->addOrderBy('e.id', 'DESC');
- // $query->setMaxResults($limit);
- // return $query->getQuery()->getResult();
- // }
-
- //countAllOpen
- public function countAllOpen($query = null)
- {
- if (is_null($query)) {
- $query = $this->query->create();
- }
- $query
- ->selectCount()
- ->filterByStatus(Ticket::TICKET_STATUS_OPEN);
-
- return $query->count();
- }
-
-
- // public function countAllOpen()
- // {
- // $query = $this->findByMerchantQuery();
- // $query->select('count(e.id)');
- // $this->filterStatus($query, [Ticket::TICKET_STATUS_OPEN]);
- // return $query->getQuery()->getSingleScalarResult();
- // }
- }
|