<?php

namespace AppBundle\Entity\Core\Repository;

use Doctrine\ORM\EntityRepository;
use Recurr\Rule;
use Recurr\Transformer\ArrayTransformer;
use Recurr\Transformer\Constraint\BetweenConstraint;
use Doctrine\ORM\Tools\Pagination\Paginator;
use Dunglas\ApiBundle\Api\ResourceInterface;
use Symfony\Component\HttpFoundation\Request;

class TipsRepository extends EntityRepository {

    public function searchActiveTips() {

        $queryBuilder= $this->createQueryBuilder('o')
            ->andWhere('o.datetimeStart <= :currentDate AND o.datetimeEnd >= :currentDate')
            ->andWhere('o.activate = true')
            ->setParameters([
                ':currentDate'=> new \DateTime()]);

        return $queryBuilder->getQuery()->getResult();
    }
}
