<?php

namespace AutoAdmin\Bundle\Admin\Repository;

use AutoAdmin\Bundle\Admin\Entity\CookieConsent;
use DateTime;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

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

    public function findBetweenDate(DateTime $from, DateTime $to)
    {
        return $this->createQueryBuilder('cc')
            ->andWhere('cc.createdAt BETWEEN :from AND :to')
            ->setParameter('from', $from)
            ->setParameter('to', $to)
            ->getQuery()
            ->getResult()
            ;
    }
}
