|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
-
- namespace Lc\ShopBundle\Repository;
-
- use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
- use Doctrine\Persistence\ManagerRegistry;
- use Lc\ShopBundle\Context\DefaultRepositoryInterface;
- use Lc\ShopBundle\Context\TicketInterface;
- use Lc\ShopBundle\Context\UnitInterface;
- use Lc\ShopBundle\Model\Ticket;
- use Lc\ShopBundle\Repository\BaseRepository;
-
- /**
- * @method TicketInterface|null find($id, $lockMode = null, $lockVersion = null)
- * @method TicketInterface|null findOneBy(array $criteria, array $orderBy = null)
- * @method TicketInterface[] findAll()
- * @method TicketInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
- class TicketRepository extends BaseRepository implements DefaultRepositoryInterface
- {
- public function getInterfaceClass()
- {
- return TicketInterface::class;
- }
-
- public function filterStatus($query, $statusArray)
- {
- $query->andWhere('e.status IN (:status)')->setParameter('status', $statusArray) ;
- return $query ;
- }
-
- 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() ;
- }
-
- public function countAllOpen()
- {
- $query = $this->findByMerchantQuery() ;
- $query->select('count(e.id)');
- $this->filterStatus($query, [Ticket::TICKET_STATUS_OPEN]) ;
- return $query->getQuery()->getSingleScalarResult() ;
- }
- }
-
|