Categories (Laravel Forum 7.x)
Categories
Endpoint paths are prefixed with the forum.router.prefix
config value (/forum/api
by default).
# Index
GET /category
Returns: a flat collection of categories (including their nested set properties).
# Fetch
GET /category/{id:int}
Returns: the category specified by {id}
if found and accessible, otherwise a 404 error.
# Store
POST /category
Creates a category with the specified parameters (see list below).
Parameters
Name | Type | Description | Default |
---|---|---|---|
title | String (required) | Title | N/A |
description | String | Description | null |
color | String | Accent color | config('forum.web.default_category_color') |
enable_threads | Boolean | Enable/disable threads | false |
is_private | Boolean | Make private or public | false |
Returns: the created category object if successful.
# Update
PATCH /category/{id:int}
Updates a category with the specified parameters (see list below).
Parameters
Name | Type | Description |
---|---|---|
title | String | Title |
description | String | Description |
color | String | Accent color |
enable_threads | Boolean | Enable/disable threads |
is_private | Boolean | Make private or public |
Returns: the updated category object if successful.
# Delete
DELETE /category/{id:int}
Deletes a category. The deletion is soft by default if the soft-deletion feature is enabled. Include force: true
in the request body to hard-delete the category.
Returns: the created category object if successful.
# Thread index
GET /category/{id:int}/thread
Returns: a paginated collection of threads belonging to the specified category.
# Store thread
POST /category/{id:int}/thread
Creates a new thread in the category specified by {id}
with the specified parameters (see list below).
Parameters
Name | Type | Description |
---|---|---|
title | String (required) | Thread title |
content | String (required) | Post content |
Returns: the created post if successful.
# Bulk manage
POST /bulk/category/manage
Bulk updates categories, including their hierarchy, based on the order and nesting of category data in the request body. Uses the rebuild tree method of kalnoy/nestedset. See example payload below.
Example payload
{
"categories": [
{
"id": 1,
"title": "New title",
"children": [
{
"id": 2
}
]
}
]
}
Returns: a generic ‘success’ response if successful.