<?php

namespace App\Repository;

use App\Entity\ReservationArticle;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<ReservationArticle>
 *
 * @method ReservationArticle|null find($id, $lockMode = null, $lockVersion = null)
 * @method ReservationArticle|null findOneBy(array $criteria, array $orderBy = null)
 * @method ReservationArticle[]    findAll()
 * @method ReservationArticle[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class ReservationArticleRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, ReservationArticle::class);
    }

    /**
     * @return ReservationArticle[] Returns an array of ReservationArticle objects
     */
    public function findBySociete($societe): array
    {
        return $this->createQueryBuilder('r')
            ->Where('r.societe = :Societe')
            ->setParameter('Societe', $societe)

            ->leftjoin('r.reservationArticleValidation', 'v')
            ->andWhere('v.id IS NULL')

            ->getQuery()
            ->getResult()
        ;
    }

//    /**
//     * @return ReservationArticle[] Returns an array of ReservationArticle objects
//     */
//    public function findByExampleField($value): array
//    {
//        return $this->createQueryBuilder('r')
//            ->andWhere('r.exampleField = :val')
//            ->setParameter('val', $value)
//            ->orderBy('r.id', 'ASC')
//            ->setMaxResults(10)
//            ->getQuery()
//            ->getResult()
//        ;
//    }

//    public function findOneBySomeField($value): ?ReservationArticle
//    {
//        return $this->createQueryBuilder('r')
//            ->andWhere('r.exampleField = :val')
//            ->setParameter('val', $value)
//            ->getQuery()
//            ->getOneOrNullResult()
//        ;
//    }
}
