src/Repository/GuardianRegister/GuardianRegisterRepository.php line 36

Open in your IDE?
  1. <?php
  2. namespace App\Repository\GuardianRegister;
  3. use App\Entity\GuardianRegister\GuardianRegister;
  4. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  5. use Doctrine\ORM\QueryBuilder;
  6. use Doctrine\Persistence\ManagerRegistry;
  7. /**
  8. * @method GuardianRegister|null find($id, $lockMode = null, $lockVersion = null)
  9. * @method GuardianRegister|null findOneBy(array $criteria, array $orderBy = null)
  10. * @method GuardianRegister[] findAll()
  11. * @method GuardianRegister[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  12. */
  13. class GuardianRegisterRepository extends ServiceEntityRepository
  14. {
  15. public function __construct(ManagerRegistry $registry)
  16. {
  17. parent::__construct($registry, GuardianRegister::class);
  18. }
  19. /**
  20. * Creates a new QueryBuilder instance that is prepopulated for this entity name.
  21. *
  22. * @param string $alias
  23. * @param string $indexBy The index for the from.
  24. *
  25. * @return QueryBuilder
  26. */
  27. public function createQueryBuilder($alias, $indexBy = null)
  28. {
  29. return $this->_em->createQueryBuilder()
  30. ->select($alias)
  31. ->from($this->_entityName, $alias, $indexBy)
  32. ->andWhere("${alias}.isDeleted = 0");
  33. }
  34. public function countNewRegistrations(): int
  35. {
  36. return (int) $this->createQueryBuilder('gr')
  37. ->select('COUNT(gr.id)')
  38. ->andWhere('gr.status = :status')
  39. ->setParameter('status', GuardianRegister::STATUS_NEW['value'])
  40. ->getQuery()
  41. ->getSingleScalarResult();
  42. }
  43. // /**
  44. // * @return GuardianRegister[] Returns an array of GuardianRegister objects
  45. // */
  46. /*
  47. public function findByExampleField($value)
  48. {
  49. return $this->createQueryBuilder('g')
  50. ->andWhere('g.exampleField = :val')
  51. ->setParameter('val', $value)
  52. ->orderBy('g.id', 'ASC')
  53. ->setMaxResults(10)
  54. ->getQuery()
  55. ->getResult()
  56. ;
  57. }
  58. */
  59. /*
  60. public function findOneBySomeField($value): ?GuardianRegister
  61. {
  62. return $this->createQueryBuilder('g')
  63. ->andWhere('g.exampleField = :val')
  64. ->setParameter('val', $value)
  65. ->getQuery()
  66. ->getOneOrNullResult()
  67. ;
  68. }
  69. */
  70. }