Last active
February 14, 2019 16:21
-
-
Save ger86/11c24d200eb6abe2b82144467704c5b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Repository; | |
| use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | |
| use Symfony\Bridge\Doctrine\RegistryInterface; | |
| use App\Repository\EntityStatsRepositoryInterface; | |
| class EntityStatsRepositoryDecorator extends ServiceEntityRepository { | |
| public function __construct( | |
| RegistryInterface $registry, | |
| ServiceEntityRepository $repository | |
| ) { | |
| parent::__construct($registry, $repository->getClassName()); | |
| } | |
| public function findTodayStats(): int { | |
| $today = new \DateTime(); | |
| return $this->createQueryBuilder('o') | |
| ->select('COUNT(o) as total') | |
| ->andWhere('o.createdAt = :today') | |
| ->setParameter('today', $today) | |
| ->getQuery() | |
| ->getSingleScalarResult(); | |
| ; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment