createQueryBuilder('ws') ->where('ws.doctor = :doctor') ->setParameter('doctor', $doctor); if ($clinic === null) { $qb->andWhere('ws.clinic IS NULL'); } else { $qb->andWhere('ws.clinic = :clinic')->setParameter('clinic', $clinic); } return $qb->setMaxResults(1)->getQuery()->getOneOrNullResult(); } /** همهٔ برنامه‌های پزشک در همهٔ contextها (شخصی + هر کلینیک). @return WeeklySchedule[] */ public function findAllByDoctor(Doctor $doctor): array { return $this->createQueryBuilder('ws') ->where('ws.doctor = :doctor') ->setParameter('doctor', $doctor) ->orderBy('ws.clinic', 'ASC') ->getQuery() ->getResult(); } /** * @deprecated برنامهٔ context شخصی را برمی‌گرداند. برای کد جدید از * findByDoctorAndClinic() استفاده کن تا context صریح باشد. */ public function findByDoctor(Doctor $doctor): ?WeeklySchedule { return $this->findByDoctorAndClinic($doctor, null); } /** @param Doctor[] $doctors @return WeeklySchedule[] */ public function findByDoctors(array $doctors): array { if (empty($doctors)) { return []; } return $this->createQueryBuilder('ws') ->where('ws.doctor IN (:doctors)') ->setParameter('doctors', $doctors) ->getQuery() ->getResult(); } public function findByUuid(string $uuid): ?WeeklySchedule { return $this->findOneBy(['uuid' => $uuid]); } public function save(WeeklySchedule $entity, bool $flush = true): void { $this->getEntityManager()->persist($entity); if ($flush) $this->getEntityManager()->flush(); } public function remove(WeeklySchedule $entity, bool $flush = true): void { $this->getEntityManager()->remove($entity); if ($flush) $this->getEntityManager()->flush(); } }