<?php
namespace App\Repository\Articles;
use App\Entity\Articles\ArticleComplementOption;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<ArticleComplementOption>
*
* @method ArticleComplementOption|null find($id, $lockMode = null, $lockVersion = null)
* @method ArticleComplementOption|null findOneBy(array $criteria, array $orderBy = null)
* @method ArticleComplementOption[] findAll()
* @method ArticleComplementOption[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ArticleComplementOptionRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ArticleComplementOption::class);
}
public function add(ArticleComplementOption $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(ArticleComplementOption $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function findEnfantsByParentAndStatus(int $parentId, int $status = 1,string $type,$client_id = 0)
{
return $this->createQueryBuilder('a')
->innerJoin('a.parent', 'p')
->innerJoin('a.enfant', 'e')
->leftJoin('e.marque', 'm')
->leftJoin('App\Entity\Clients\ClientMarque','ccm',\Doctrine\ORM\Query\Expr\Join::WITH,'ccm.marque = e.marque AND ccm.client = :clientId')
->where('p.id = :parentId')
->andWhere('e.statut = :status')
->andWhere('a.type = :type')
->andWhere('(m.id is null or m.statut = 1)')
->andWhere('ccm.id IS NULL')
->setParameter('parentId', $parentId)
->setParameter('status', $status)
->setParameter('type', $type)
->setParameter('clientId', $client_id)
->getQuery()
->getResult();
}
// /**
// * @return ArticleComplementOption[] Returns an array of ArticleComplementOption objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('a')
// ->andWhere('a.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('a.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?ArticleComplementOption
// {
// return $this->createQueryBuilder('a')
// ->andWhere('a.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}