feat(clinic): implement doctor detachment functionality with API endpoint and confirmation dialog

This commit is contained in:
hamed
2026-06-19 01:10:06 +03:30
parent b3883a6e90
commit dd1ca98cb4
4 changed files with 106 additions and 0 deletions
@@ -330,6 +330,43 @@ class ClinicController extends BaseController
]);
}
#[OA\Delete(
path: '/api/v1/admin/clinic/{clinicUuid}/doctor/{doctorUuid}',
summary: 'Detach a doctor from a clinic (admin only)',
security: [['bearerAuth' => []]],
parameters: [
new OA\Parameter(name: 'clinicUuid', in: 'path', required: true, schema: new OA\Schema(type: 'string', format: 'uuid')),
new OA\Parameter(name: 'doctorUuid', in: 'path', required: true, schema: new OA\Schema(type: 'string', format: 'uuid')),
],
responses: [
new OA\Response(response: 200, description: 'Doctor detached from clinic'),
new OA\Response(response: 404, description: 'Clinic or doctor not found'),
]
)]
#[Route('/api/v1/admin/clinic/{clinicUuid}/doctor/{doctorUuid}', methods: ['DELETE'])]
#[IsGranted('ROLE_ADMIN')]
public function detachDoctor(string $clinicUuid, string $doctorUuid): JsonResponse
{
$clinic = $this->clinicRepo->findByUuid($clinicUuid);
if ($clinic === null) {
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'کلینیک یافت نشد', 404);
}
$doctor = $this->doctorRepo->findByUuid($doctorUuid);
if ($doctor === null) {
return $this->error(ErrorCodes::ERR_NOT_FOUND_001, 'پزشک یافت نشد', 404);
}
if (!$clinic->hasDoctor($doctor)) {
return $this->error(ErrorCodes::ERR_NOT_FOUND_001, 'این پزشک به کلینیک متصل نیست', 404);
}
$clinic->removeDoctor($doctor);
$this->clinicRepo->save($clinic);
return $this->success(['message' => 'پزشک از کلینیک جدا شد']);
}
#[OA\Post(
path: '/file/upload/clinic_pro/clinic/field_image_clinic',
summary: 'Upload a clinic gallery image',
+10
View File
@@ -147,6 +147,16 @@ class Clinic
public function getCreatedAt(): int { return $this->createdAt; }
public function getUpdatedAt(): int { return $this->updatedAt; }
public function getDoctors(): Collection { return $this->doctors; }
public function hasDoctor(Doctor $doctor): bool { return $this->doctors->contains($doctor); }
public function removeDoctor(Doctor $doctor): self
{
$this->doctors->removeElement($doctor);
$this->touch();
return $this;
}
public function getSpecialties(): Collection { return $this->specialties; }
public function getServices(): Collection { return $this->services; }
public function getInsurances(): Collection { return $this->insurances; }