feat: add holiday management endpoints and jalaali-js dependency

- Added a new endpoint to list holidays for a specific doctor.
- Added a new endpoint to delete a holiday, with access control for doctors and admins.
- Implemented a repository method to retrieve all holidays for a doctor.
- Added jalaali-js library to handle date conversions.
This commit is contained in:
hamed
2026-06-10 17:41:04 +03:30
parent a5876b9324
commit d489702751
6 changed files with 775 additions and 20 deletions
@@ -223,6 +223,36 @@ class AppointmentSettingsController extends BaseController
// ── Holidays ──────────────────────────────────────────────────────────────
#[Route('/api/v1/appointment-settings/holidays/list/{doctorUuid}', methods: ['GET'])]
public function listHolidays(string $doctorUuid): JsonResponse
{
$doctor = $this->doctorRepo->findByUuid($doctorUuid);
if ($doctor === null) {
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'دکتر یافت نشد', 404);
}
$items = array_map(fn(Holiday $h) => $h->toArray(), $this->holidayRepo->findAllByDoctor($doctor));
return $this->success(['data' => $items]);
}
#[Route('/api/v1/appointment-settings/holidays/{uuid}', methods: ['DELETE'])]
public function deleteHoliday(string $uuid, #[CurrentUser] User $user): JsonResponse
{
$holiday = $this->holidayRepo->findByUuid($uuid);
if ($holiday === null) {
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'تعطیلات یافت نشد', 404);
}
if ($holiday->getDoctor()->getUser()->getId() !== $user->getId() && !$user->hasRole('ROLE_ADMIN')) {
return $this->error(ErrorCodes::ERR_AUTH_006, 'دسترسی ممنوع', 403);
}
$this->holidayRepo->remove($holiday);
return $this->success(['message' => 'تعطیلات حذف شد']);
}
#[Route('/api/v1/appointment-settings/holidays', methods: ['POST'])]
public function createHoliday(Request $request, #[CurrentUser] User $user): JsonResponse
{