| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Repository;
- use App\Entity\Genre;
- use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
- use Doctrine\Persistence\ManagerRegistry;
- /**
- * @method Genre|null find($id, $lockMode = null, $lockVersion = null)
- * @method Genre|null findOneBy(array $criteria, array $orderBy = null)
- * @method Genre[] findAll()
- * @method Genre[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
- */
- /**
- * GenreRepository
- *
- * This class was generated by the Doctrine ORM. Add your own custom
- * repository methods below.
- */
- class GenreRepository extends ServiceEntityRepository
- {
- public function __construct(ManagerRegistry $registry)
- {
- parent::__construct($registry, Genre::class);
- }
- public function findGenres (): array
- {
- $qb = $this->createQueryBuilder('g');
- $query = $qb
- ->select('g.name')
- ->getQuery();
- return $query->getArrayResult();
- }
- public function findGenreLike(?string $query = null): ?array
- {
- $qb = $this->createQueryBuilder('g');
- $qb
- ->where($qb->expr()->like('g.name', ':genreName'))
- ->setParameter('genreName', '%'.$query.'%')
- ;
- return $qb->getQuery()->getResult();
- }
- }
|