add progression
This commit is contained in:
28
src/Repository/ProjetRepository.php
Normal file
28
src/Repository/ProjetRepository.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user