feat(specialty): public doctor-counts endpoint (per city)

Add GET /api/v1/specialties/doctor-counts?city_id= returning every active
specialty with number_of_doctors (distinct doctors via doctor_specialties,
scoped by doctor_cities when city_id is given). Make /api/v1/specialties GET
public. Powers the /specialties page count. Docs updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-16 22:27:27 +03:30
co-authored by Claude Opus 4.8
parent 28011160a2
commit 404dd03247
5 changed files with 205 additions and 1 deletions
+33
View File
@@ -42,6 +42,39 @@ List all medical specialties.
---
## GET `/api/v1/specialties/doctor-counts`
List active specialties together with the number of doctors in each — optionally scoped to a city. Used by the public `/specialties` page to show «N پزشک» under each specialty.
**Permission:** `PUBLIC`
### Query Parameters
| Param | Type | Required | Description |
|-------|------|----------|-------------|
| `city_id` | integer | ❌ | Count only doctors in this city (the `categories.id` of the city). Omit for a global count. |
### Response `200`
```json
{
"success": true,
"data": [
{
"id": 2,
"name": "داخلی عمومی",
"slug": "...",
"parent_id": null,
"status": "active",
"weight": 10,
"number_of_doctors": 10
}
]
}
```
- Returns **all** active specialties; those with no doctors have `number_of_doctors: 0`.
- `number_of_doctors` counts distinct doctors joined through `doctor_specialties` (and `doctor_cities` when `city_id` is given), matching the public `GET /api/v1/doctors?specialty_id=&city_id=` filter.
---
## GET `/api/v1/admin/specialties`
List all specialties with pagination (admin view — includes inactive).