API: Toggle Coach Configuration Status

Request

Toggle the status of a specific coach configuration (active/inactive):

PATCH /coach-configurations/{id}/toggle-status

Sample Request:

PATCH /coach-configurations/1/toggle-status

Sample Response:


{
  "success": true,
  "message": "Coach configuration status updated successfully",
  "data": {
    "id": 1,
    "coach_id": 1,
    "schedule_id": 2,
    "bus_id": 3,
    "seat_plan_id": 4,
    "route_id": 5,
    "coach_type": 1,
    "status": 0,
    "created_by": 1,
    "updated_by": 1,
    "created_at": "2025-08-10T10:00:00.000000Z",
    "updated_at": "2025-08-10T11:30:00.000000Z"
  }
}
                

Status Toggle Behavior:

  • Active to Inactive - If current status is 1 (active), it will be changed to 0 (inactive)
  • Inactive to Active - If current status is 0 (inactive), it will be changed to 1 (active)
  • Automatic Update - The updated_at timestamp and updated_by field are automatically set
  • No Request Body - This endpoint doesn't require any request body data

Use Cases:

  • Quick Activation/Deactivation - Rapidly enable or disable coach configurations
  • Maintenance Mode - Temporarily disable configurations during maintenance
  • Emergency Suspension - Quickly deactivate configurations due to emergencies
  • Seasonal Operations - Enable/disable configurations based on seasonal demand
  • Admin Control - Provide simple toggle functionality in admin interfaces

Response Details:

  • Updated Configuration - Returns the coach configuration with new status
  • Minimal Data - Only returns basic configuration data without related models
  • Audit Trail - Shows who updated the status and when
  • Status Confirmation - Clear indication of the new status value

Notes:

  • The coach configuration ID is required in the URL path.
  • If the coach configuration does not exist, the API will return a 404 error.
  • This is a lightweight operation that only changes the status field.
  • The operation is idempotent - multiple calls will toggle between states.
  • Related boarding/dropping points are not affected by status changes.

Error Responses:

404 Not Found

{
  "success": false,
  "message": "Coach configuration not found"
}
                
500 Server Error

{
  "success": false,
  "message": "Failed to update coach configuration status: Database connection error"
}