29 lines
802 B
PHP
29 lines
802 B
PHP
<?php
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\Projet;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
class ProjetRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, Projet::class);
|
|
}
|
|
|
|
/**
|
|
* Vérifie si un projet possède des contributions.
|
|
*/
|
|
public function hasContributions(Projet $projet): bool
|
|
{
|
|
$qb = $this->getEntityManager()->createQueryBuilder();
|
|
$qb->select('count(c.id)')
|
|
->from('App\\Entity\\Contribution', 'c')
|
|
->where('c.projet = :projet')
|
|
->setParameter('projet', $projet);
|
|
return $qb->getQuery()->getSingleScalarResult() > 0;
|
|
}
|
|
}
|