Skip to content

Conversation

@snipe
Copy link
Member

@snipe snipe commented Nov 4, 2025

This PR fixes #18148 and #17451, correctly now returning the users count when viewing a specific department via API, casting it as an integer, and also fixes the validation. Previously, the validation wasn't working as expected, so you could have repeated department names. The validator now correctly checks for uniqueness across company and location ID (if they are provided.)

This is technically a breaking change, since we're also now using the transformers to format the create/update responses, however I don't think most folks use the departments API endpoint much, since the validation issue has been a bug forever and nobody mentioned it.

{
    "status": "success",
    "messages": "Department updated successfully.",
    "payload": {
        "id": 30,
        "name": "Test from API",
        "phone": null,
        "fax": null,
        "image": null,
        "company": {
            "id": 2,
            "name": "Lowe LLC"
        },
        "manager": null,
        "location": {
            "id": 5,
            "name": "East Chadrickstad"
        },
        "users_count": 0,
        "notes": "TEST AGAIN",
        "created_at": {
            "datetime": "2025-11-04 15:30:24",
            "formatted": "Tue Nov 04, 2025 3:30PM"
        },
        "updated_at": {
            "datetime": "2025-11-04 16:02:09",
            "formatted": "Tue Nov 04, 2025 4:02PM"
        },
        "available_actions": {
            "update": true,
            "delete": true
        }
    }
}

I also think the custom validator is a little less horrible-looking now.

@snipe snipe added api breaking This is a potentially breaking change labels Nov 4, 2025
@snipe snipe requested a review from uberbrady November 4, 2025 16:03
@snipe snipe merged commit b7a6706 into develop Nov 4, 2025
8 checks passed
@snipe snipe deleted the #18148-dept-api-request-user-count branch November 4, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api breaking This is a potentially breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants