Categories (Laravel Forum 6.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

NameTypeDescriptionDefault
titleString (required)TitleN/A
descriptionStringDescriptionnull
colorStringAccent colorconfig('forum.web.default_category_color')
enable_threadsBooleanEnable/disable threadsfalse
is_privateBooleanMake private or publicfalse

Returns: the created category object if successful.

# Update

PATCH /category/{id:int}

Updates a category with the specified parameters (see list below).

Parameters

NameTypeDescription
titleStringTitle
descriptionStringDescription
colorStringAccent color
enable_threadsBooleanEnable/disable threads
is_privateBooleanMake 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

NameTypeDescription
titleString (required)Thread title
contentString (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.