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:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user