39 lines
941 B
PHP
39 lines
941 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\Bonus;
|
|
use DateTimeImmutable;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<Bonus>
|
|
*/
|
|
final class BonusRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, Bonus::class);
|
|
}
|
|
|
|
/**
|
|
* @return Bonus[]
|
|
*/
|
|
public function findByMonth(DateTimeImmutable $from, DateTimeImmutable $to): array
|
|
{
|
|
return $this->createQueryBuilder('b')
|
|
->andWhere('b.month >= :from')
|
|
->andWhere('b.month <= :to')
|
|
->setParameter('from', $from)
|
|
->setParameter('to', $to)
|
|
->innerJoin('b.employee', 'e')
|
|
->addSelect('e')
|
|
->getQuery()
|
|
->getResult()
|
|
;
|
|
}
|
|
}
|