<?php

namespace App\Repository;

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

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

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

//    /**
//     * @return ReservationServiceValidation[] Returns an array of ReservationServiceValidation 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): ?ReservationServiceValidation
//    {
//        return $this->createQueryBuilder('r')
//            ->andWhere('r.exampleField = :val')
//            ->setParameter('val', $value)
//            ->getQuery()
//            ->getOneOrNullResult()
//        ;
//    }
}
