feat : add ClientTicketRepository
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
src/Repository/ClientTicketRepository.php
Normal file
34
src/Repository/ClientTicketRepository.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\ClientTicket;
|
||||||
|
use App\Entity\Project;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<ClientTicket>
|
||||||
|
*/
|
||||||
|
class ClientTicketRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, ClientTicket::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findNextNumberForProject(Project $project): int
|
||||||
|
{
|
||||||
|
$result = $this->createQueryBuilder('ct')
|
||||||
|
->select('MAX(ct.number)')
|
||||||
|
->where('ct.project = :project')
|
||||||
|
->setParameter('project', $project)
|
||||||
|
->getQuery()
|
||||||
|
->getSingleScalarResult()
|
||||||
|
;
|
||||||
|
|
||||||
|
return ((int) $result) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user