Add method to retrieve ordered staff notes

This commit is contained in:
Ryan Prather 2024-12-22 22:57:52 +00:00
parent c5b8148f00
commit 91110c037e

View File

@ -2,6 +2,7 @@
namespace App\Repository; namespace App\Repository;
use App\Entity\MemberCase;
use App\Entity\StaffNote; use App\Entity\StaffNote;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
@ -16,6 +17,16 @@ class StaffNoteRepository extends ServiceEntityRepository
parent::__construct($registry, StaffNote::class); parent::__construct($registry, StaffNote::class);
} }
public function getOrderedNotes(MemberCase $case): array
{
return $this->createQueryBuilder('s')
->andWhere('s.memberCase = :case')
->setParameter('case', $case->getId()->toBinary())
->orderBy('s.date', 'DESC')
->getQuery()
->getResult();
}
// /** // /**
// * @return StaffNote[] Returns an array of StaffNote objects // * @return StaffNote[] Returns an array of StaffNote objects
// */ // */