64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\Employee;
|
|
use App\Entity\EmployeeRttPayment;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<EmployeeRttPayment>
|
|
*/
|
|
final class EmployeeRttPaymentRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, EmployeeRttPayment::class);
|
|
}
|
|
|
|
public function findOneByEmployeeYearMonth(Employee $employee, int $year, int $month): ?EmployeeRttPayment
|
|
{
|
|
return $this->findOneBy([
|
|
'employee' => $employee,
|
|
'year' => $year,
|
|
'month' => $month,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @return EmployeeRttPayment[]
|
|
*/
|
|
public function findByEmployeeAndYear(Employee $employee, int $year): array
|
|
{
|
|
return $this->createQueryBuilder('p')
|
|
->andWhere('p.employee = :employee')
|
|
->andWhere('p.year = :year')
|
|
->setParameter('employee', $employee)
|
|
->setParameter('year', $year)
|
|
->addOrderBy('p.month', 'ASC')
|
|
->getQuery()
|
|
->getResult()
|
|
;
|
|
}
|
|
|
|
/**
|
|
* @return EmployeeRttPayment[]
|
|
*/
|
|
public function findByYearAndMonth(int $year, int $month): array
|
|
{
|
|
return $this->createQueryBuilder('p')
|
|
->andWhere('p.year = :year')
|
|
->andWhere('p.month = :month')
|
|
->setParameter('year', $year)
|
|
->setParameter('month', $month)
|
|
->innerJoin('p.employee', 'e')
|
|
->addSelect('e')
|
|
->getQuery()
|
|
->getResult()
|
|
;
|
|
}
|
|
}
|