<?php

namespace App\Repository;

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

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

    /**
     * @return ReservationArticleValidation[] Returns an array of ReservationArticleValidation objects
     */
    public function findBySociete($societe): array
    {
        return $this->createQueryBuilder('v')
            
            ->innerJoin('v.reservationArticle', 'ra')
            ->andWhere('ra.societe = :Societe')
            ->setParameter('Societe', $societe)
            //->orderBy('r.id', 'ASC')
            ->getQuery()
            ->getResult()
        ;
    }

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