Laravel Forum 4.x Documentation

General - Policies

Policies

Four Authorization Policies are defined to provide default permission checks. You can override them and change the corresponding namespaces specified in the forum.integration.policies config value to allow or deny forum abilities to different users.

Note that every policy method must return a boolean (true to allow or false to deny).

Forum

Riari\Forum\Policies\ForumPolicy

This policy defines a few top-level abilities that don’t apply to a specific category, thread or post.

Methods in this policy accept a $user parameter.

AbilityDescription
createCategoriesAllows creating categories at any level.
manageCategoriesEncompasses category modifying/deleting abilities.
moveCategoriesAllows relocating and reordering categories.
renameCategoriesAllows changing a category’s title and description.
markNewThreadsAsReadAllows marking new/updated threads as ‘read’.
viewTrashedThreadsAllows viewing threads that have been soft-deleted.
viewTrashedPostsAllows viewing posts that have been soft-deleted.

Category

Riari\Forum\Policies\CategoryPolicy

This policy defines abilities pertaining to individual categories.

Methods in this policy accept $user and $category parameters.

AbilityDescription
createThreadsAllows new thread creation in the category.
manageThreadsEncompasses thread modifying/deleting abilities in the category.
deleteThreadsAllows deleting threads in the category.
enableThreadsAllows enabling or disabling thread creation in the category.
moveThreadsFromAllows moving threads from the category.
moveThreadsToAllows moving threads to the category.
lockThreadsAllows (un)locking of threads in the category.
pinThreadsAllows (un)pinning of threads in the category.
viewAllows viewing the category (if it’s set to be private).
deleteAllows deletion of the category.

Thread

Riari\Forum\Policies\ThreadPolicy

This policy defines abilities pertaining to individual threads.

Methods in this policy accept $user and $thread parameters.

AbilityDescription
deletePostsAllows deleting posts in the thread.
renameAllows renaming the thread.
replyAllows replying to the thread (creating a new post).
deleteAllows deletion of the thread.

Post

Riari\Forum\Policies\PostPolicy

This policy defines abilities pertaining to individual posts.

Methods in this policy accept $user and $post parameters.

AbilityDescription
editAllows editing the post.
deleteAllows deletion of the post. Depends on ThreadPolicy’s deletePosts ability.