first commit

This commit is contained in:
BRAMAS Arthur
2025-10-16 17:09:34 +02:00
parent 02765a025e
commit 00a7a1665b
6 changed files with 129 additions and 10 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Repository;
use App\Entity\Projet;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Projet>
*/
class ProjetRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Projet::class);
}
// 🔹 Exemple : trouver un projet par son nom
public function findByName(string $name): ?Projet
{
return $this->createQueryBuilder('p')
->andWhere('p.name = :name')
->setParameter('name', $name)
->getQuery()
->getOneOrNullResult();
}
// 🔹 Exemple : récupérer tous les projets actifs
public function findActiveProjects(): array
{
return $this->createQueryBuilder('p')
->andWhere('p.isActive = :active')
->setParameter('active', true)
->orderBy('p.createdAt', 'DESC')
->getQuery()
->getResult();
}
}