Entities & Repos

This commit is contained in:
2024-05-13 21:08:21 -04:00
parent 21f014d08d
commit 658b021962
15 changed files with 1552 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace App\Repository;
use App\Entity\Bible;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Bible>
*/
class BibleRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Bible::class);
}
public function findRange(Bible $bible, array $passage): array
{
return $this->createQueryBuilder('b')
->andWhere('b.book = :book')
->andWhere('b.chapter = :chapter')
->andWhere('b.verse BETWEEN :verseStart AND :verseEnd')
->setParameter('book', $bible->getBook())
->setParameter('chapter', $bible->getChapter())
->setParameter('verseStart', $passage[0])
->setParameter('verseEnd', $passage[1])
->getQuery()
->getResult();
}
// /**
// * @return Bible[] Returns an array of Bible objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('b')
// ->andWhere('b.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('b.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Bible
// {
// return $this->createQueryBuilder('b')
// ->andWhere('b.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}