feat(appointments): only doctors with a weekly schedule get a tab
my/clinic-doctors now reports has_schedule per doctor, and the appointments page builds tabs from it. A doctor with no working days had a tab that could only ever show an empty timeline. The flag is resolved with one query for the whole list rather than one per doctor. Clinic owners now read this authenticated endpoint too instead of the public clinic doctor-list, which is where the flag lives; admin keeps the public list and, with no flag present, hides nobody. Also repairs fallout from making the resource supervisor mandatory: four test classes build resources through their own helpers and were failing with 422. The supervisorFor helper moved to ApiTestCase so all domains share one, rather than copying it per suite. Full backend suite is green again (1306 tests) — the previous commit only ran tests/Resource and missed this. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,7 @@ class MyAppointmentsController extends BaseController
|
||||
private readonly \App\UserProfile\Repository\UserProfileRepository $profileRepo,
|
||||
private readonly VisitPriceRequirementResolver $visitPriceResolver,
|
||||
private readonly \App\Shared\Tenant\TenantOwnershipChecker $tenantOwnership,
|
||||
private readonly \App\Appointment\Repository\WeeklyScheduleRepository $scheduleRepo,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -77,12 +78,28 @@ class MyAppointmentsController extends BaseController
|
||||
$doctors = $doctor !== null ? [$doctor] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* `has_schedule`: آیا این پزشک در محیط جاری برنامهٔ کاری تعریف کرده؟
|
||||
*
|
||||
* صفحهٔ نوبتها فقط برای پزشکِ دارای برنامه تب میسازد — تبِ پزشکی که روز کاری
|
||||
* ندارد جز یک تایملاین همیشهخالی چیزی نشان نمیدهد. یک کوئری برای کل فهرست
|
||||
* گرفته میشود، نه یکی بهازای هر پزشک.
|
||||
*/
|
||||
$scheduledDoctorIds = [];
|
||||
foreach ($this->scheduleRepo->findByDoctors($doctors) as $schedule) {
|
||||
$scheduledDoctorIds[(int) $schedule->getDoctor()->getId()] = true;
|
||||
}
|
||||
|
||||
$data = array_map(
|
||||
static fn(Doctor $d) => ['uuid' => $d->getUuid(), 'name' => $d->getName()],
|
||||
static fn(Doctor $d) => [
|
||||
'uuid' => $d->getUuid(),
|
||||
'name' => $d->getName(),
|
||||
'has_schedule' => isset($scheduledDoctorIds[(int) $d->getId()]),
|
||||
],
|
||||
$doctors,
|
||||
);
|
||||
|
||||
return $this->success(['data' => $data]);
|
||||
return $this->success(['data' => array_values($data)]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/my/appointment', methods: ['POST'])]
|
||||
|
||||
Reference in New Issue
Block a user