62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Repository;
|
||
|
|
||
|
use App\Entity\Note;
|
||
|
use App\Entity\Referral;
|
||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||
|
use Doctrine\Persistence\ManagerRegistry;
|
||
|
|
||
|
/**
|
||
|
* @extends ServiceEntityRepository<Notes>
|
||
|
*/
|
||
|
class NoteRepository extends ServiceEntityRepository
|
||
|
{
|
||
|
public function __construct(ManagerRegistry $registry)
|
||
|
{
|
||
|
parent::__construct($registry, Note::class);
|
||
|
}
|
||
|
|
||
|
public function getHoursUsed(Referral $referral): int
|
||
|
{
|
||
|
$ret = 0;
|
||
|
|
||
|
$query = $this->createQueryBuilder('n')
|
||
|
->select('SUM(n.hours) AS hours')
|
||
|
->andWhere('n.referral = :referral')
|
||
|
->setParameter('referral', $referral->getId()->toBinary())
|
||
|
->getQuery()
|
||
|
//->getResult()
|
||
|
;
|
||
|
|
||
|
dd($query->getSQL());
|
||
|
|
||
|
return $ret;
|
||
|
}
|
||
|
|
||
|
// /**
|
||
|
// * @return Notes[] Returns an array of Notes objects
|
||
|
// */
|
||
|
// public function findByExampleField($value): array
|
||
|
// {
|
||
|
// return $this->createQueryBuilder('n')
|
||
|
// ->andWhere('n.exampleField = :val')
|
||
|
// ->setParameter('val', $value)
|
||
|
// ->orderBy('n.id', 'ASC')
|
||
|
// ->setMaxResults(10)
|
||
|
// ->getQuery()
|
||
|
// ->getResult()
|
||
|
// ;
|
||
|
// }
|
||
|
|
||
|
// public function findOneBySomeField($value): ?Notes
|
||
|
// {
|
||
|
// return $this->createQueryBuilder('n')
|
||
|
// ->andWhere('n.exampleField = :val')
|
||
|
// ->setParameter('val', $value)
|
||
|
// ->getQuery()
|
||
|
// ->getOneOrNullResult()
|
||
|
// ;
|
||
|
// }
|
||
|
}
|