FreeLearning record via User::enrollFreeLearning(). Served by FreeLearningController::enroll().App\Http\Controllers\Api\V1\Diver\FreeLearningController::enroll()api.v1.diver.free-learnings.enrollAuthorization: Bearer {token}POST/api/v1/diver/free-learnings/enrollapplication/json{
"course_id": 83
}| Field | Type | Required | Validation | Description |
|---|---|---|---|---|
course_id | integer | Yes | required|integer|exists:courses,id (active, credit_id not null, course_type = 'course', is_renew = false, is_free_learning = true) | A course listed by GET /api/v1/diver/free-learnings/available (before the exclusion of held courses). No role filter |
App\Http\Requests\Api\V1\Diver\EnrollFreeLearningRequest, extends ApiFormRequest — full envelope 422.201 Created{
"success": true,
"status": "success",
"message": "Enrolled successfully",
"data": {
"log_code": "24c6d5ce109a0f9e0595fba33fb38947",
"course": { "id": 83, "name": "Wreck Instructor Trainer" }
}
}| Field | Type | Nullable | Notes |
|---|---|---|---|
log_code | string(32) | No | Newly generated, use to address this enrollment on every other free-learning endpoint |
course.id | integer | No | |
course.name | string | No |
401 Unauthorized{
"success": false,
"status": "error",
"message": "Unauthenticated"
}409 Conflict - already held{
"success": false,
"status": "error",
"message": "Already enrolled in this course"
}422 Unprocessable Entity — validation{
"success": false,
"status": "error",
"message": "Validation failed",
"errors": {
"course_id": ["The course id field is required."]
}
}FreeLearning row via User::enrollFreeLearning().credit_id, a renewal course or a course with is_free_learning = false answers 422.available_courses_with_free_learning) immediately before the insert - TO VERIFY under concurrent requests.docs/api/diver/free-learnings/POST_enroll.mdcurl --location 'https://test.diveraid.com/api/v1/diver/free-learnings/enroll' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"course_id": 0
}'{
"status": "success",
"message": "string",
"data": {
"log_code": "string",
"course": {
"id": 0,
"name": "string"
}
}
}