src/Repository/SAVRepository.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use App\Entity\SAV;
  4. use DateTime;
  5. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  6. use Doctrine\Persistence\ManagerRegistry;
  7. /**
  8.  * @extends ServiceEntityRepository<SAV>
  9.  *
  10.  * @method SAV|null find($id, $lockMode = null, $lockVersion = null)
  11.  * @method SAV|null findOneBy(array $criteria, array $orderBy = null)
  12.  * @method SAV[]    findAll()
  13.  * @method SAV[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  14.  */
  15. class SAVRepository extends ServiceEntityRepository
  16. {
  17.     public function __construct(ManagerRegistry $registry)
  18.     {
  19.         parent::__construct($registrySAV::class);
  20.     }
  21.     public function add(SAV $entitybool $flush false): void
  22.     {
  23.         $this->getEntityManager()->persist($entity);
  24.         if ($flush) {
  25.             $this->getEntityManager()->flush();
  26.         }
  27.     }
  28.     public function remove(SAV $entitybool $flush false): void
  29.     {
  30.         $this->getEntityManager()->remove($entity);
  31.         if ($flush) {
  32.             $this->getEntityManager()->flush();
  33.         }
  34.     }
  35.     /**
  36.      * @return SAV[] Returns an array of SAV objects
  37.      */
  38.     public function findSAVenCours(): array
  39.     {
  40.         return $this->createQueryBuilder('s')
  41.             ->andWhere('s.dateCloture IS NULL OR s.dateCloture >= :today')
  42.             ->andWhere('s.installation = false')
  43.             ->setParameter('today', (new DateTime('now'))->setTime(00,01,0))
  44.             ->getQuery()
  45.             ->getResult()
  46.         ;
  47.     }
  48.     /**
  49.      * @return SAV[] Returns an array of SAV objects
  50.      */
  51.     public function findAllSAVsByMachine($machine): array
  52.     {
  53.         return $this->createQueryBuilder('s')
  54.             ->andWhere('s.machine = :machine')
  55.             ->setParameter('machine'$machine->getId())
  56.             ->andWhere('s.installation = false')
  57.             ->getQuery()
  58.             ->getResult()
  59.             ;
  60.     }
  61. //    public function findOneBySomeField($value): ?SAV
  62. //    {
  63. //        return $this->createQueryBuilder('s')
  64. //            ->andWhere('s.exampleField = :val')
  65. //            ->setParameter('val', $value)
  66. //            ->getQuery()
  67. //            ->getOneOrNullResult()
  68. //        ;
  69. //    }
  70. }