src/Repository/Articles/ArticleComplementOptionRepository.php line 42

Open in your IDE?
  1. <?php
  2. namespace App\Repository\Articles;
  3. use App\Entity\Articles\ArticleComplementOption;
  4. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. /**
  7.  * @extends ServiceEntityRepository<ArticleComplementOption>
  8.  *
  9.  * @method ArticleComplementOption|null find($id, $lockMode = null, $lockVersion = null)
  10.  * @method ArticleComplementOption|null findOneBy(array $criteria, array $orderBy = null)
  11.  * @method ArticleComplementOption[]    findAll()
  12.  * @method ArticleComplementOption[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  13.  */
  14. class ArticleComplementOptionRepository extends ServiceEntityRepository
  15. {
  16.     public function __construct(ManagerRegistry $registry)
  17.     {
  18.         parent::__construct($registryArticleComplementOption::class);
  19.     }
  20.     public function add(ArticleComplementOption $entitybool $flush false): void
  21.     {
  22.         $this->getEntityManager()->persist($entity);
  23.         if ($flush) {
  24.             $this->getEntityManager()->flush();
  25.         }
  26.     }
  27.     public function remove(ArticleComplementOption $entitybool $flush false): void
  28.     {
  29.         $this->getEntityManager()->remove($entity);
  30.         if ($flush) {
  31.             $this->getEntityManager()->flush();
  32.         }
  33.     }
  34.     public function findEnfantsByParentAndStatus(int $parentIdint $status 1,string $type,$client_id 0)
  35.     {
  36.         return $this->createQueryBuilder('a')
  37.             ->innerJoin('a.parent''p')
  38.             ->innerJoin('a.enfant''e')
  39.             ->leftJoin('e.marque''m')
  40.             ->leftJoin('App\Entity\Clients\ClientMarque','ccm',\Doctrine\ORM\Query\Expr\Join::WITH,'ccm.marque = e.marque AND ccm.client = :clientId')
  41.             ->where('p.id = :parentId')
  42.             ->andWhere('e.statut = :status')
  43.             ->andWhere('a.type = :type')
  44.             ->andWhere('(m.id is null or m.statut = 1)')
  45.             ->andWhere('ccm.id IS NULL')
  46.             ->setParameter('parentId'$parentId)
  47.             ->setParameter('status'$status)
  48.             ->setParameter('type'$type)
  49.             ->setParameter('clientId'$client_id)
  50.             ->getQuery()
  51.             ->getResult();
  52.     }
  53. //    /**
  54. //     * @return ArticleComplementOption[] Returns an array of ArticleComplementOption objects
  55. //     */
  56. //    public function findByExampleField($value): array
  57. //    {
  58. //        return $this->createQueryBuilder('a')
  59. //            ->andWhere('a.exampleField = :val')
  60. //            ->setParameter('val', $value)
  61. //            ->orderBy('a.id', 'ASC')
  62. //            ->setMaxResults(10)
  63. //            ->getQuery()
  64. //            ->getResult()
  65. //        ;
  66. //    }
  67. //    public function findOneBySomeField($value): ?ArticleComplementOption
  68. //    {
  69. //        return $this->createQueryBuilder('a')
  70. //            ->andWhere('a.exampleField = :val')
  71. //            ->setParameter('val', $value)
  72. //            ->getQuery()
  73. //            ->getOneOrNullResult()
  74. //        ;
  75. //    }
  76. }