File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public function duration(): int
5656 return $ this ->duration ;
5757 }
5858
59- public function doctor (): Doctor
59+ public function doctor (): int
6060 {
6161 return $ this ->doctor ;
6262 }
Original file line number Diff line number Diff line change 44
55namespace App \Core \Visit \Service \AddVisit ;
66
7- use App \Core \Doctor \Entity \Doctor ;
8- use App \Core \Doctor \Repository \DoctorRepository ;
97use App \Core \Visit \Entity \Visit ;
108use Doctrine \ORM \EntityManagerInterface ;
119
1210final class AddVisitService
1311{
1412 private EntityManagerInterface $ manager ;
15- private DoctorRepository $ repository ;
1613
17- public function __construct (EntityManagerInterface $ manager, DoctorRepository $ repository )
14+ public function __construct (EntityManagerInterface $ manager )
1815 {
1916 $ this ->manager = $ manager ;
20- $ this ->repository = $ repository ;
2117 }
2218
2319 public function __invoke (AddVisitInput $ input ): void
2420 {
25- $ doctor = $ this ->repository ->find ($ input ->doctorId ());
26-
27- if (!$ doctor instanceof Doctor) {
28- throw new \RuntimeException ('Doctor not found ' );
29- }
30-
3121 $ visit = new Visit (
3222 $ input ->date (),
3323 $ input ->duration (),
34- $ doctor
24+ ( int ) $ input -> doctorId ()
3525 );
3626
3727 $ this ->manager ->persist ($ visit );
Original file line number Diff line number Diff line change 44
55namespace App \Core \Visit \Service \GetDoctorVisits ;
66
7- use App \Core \Doctor \Repository \DoctorRepository ;
87use App \Core \Visit \Entity \Visit ;
98use App \Core \Visit \Repository \VisitRepository ;
109
1110final class GetDoctorVisitsService
1211{
1312 private VisitRepository $ visitRepository ;
14- private DoctorRepository $ doctorRepository ;
1513
16- public function __construct (VisitRepository $ visitRepository, DoctorRepository $ doctorRepository )
14+ public function __construct (VisitRepository $ visitRepository )
1715 {
1816 $ this ->visitRepository = $ visitRepository ;
19- $ this ->doctorRepository = $ doctorRepository ;
2017 }
2118
2219 /**
2320 * @return Visit[]
2421 */
2522 public function __invoke (string $ doctorId ): array
2623 {
27- $ doctor = $ this ->doctorRepository ->find ($ doctorId );
28-
29- return $ this ->visitRepository ->findBy (['doctor ' => $ doctor ]);
24+ return $ this ->visitRepository ->findBy (['doctor ' => $ doctorId ]);
3025 }
3126}
You can’t perform that action at this time.
0 commit comments