Laravel Comments
Comments for Laravel Rust models: replies to any depth, moderation, reactions and mentions, with a page of threads read in seven queries.
Comments for blog posts, products, tasks, anything your application has. Replies nest to any depth, moderation keeps spam out, reactions count themselves, and a page of threads with authors, reactions, and the viewer's own reactions is read in seven queries, however many comments it holds.
The package is the backend only. You draw the comments with whatever your application uses: a MiniJinja template, Inertia and React, or htmx.
Features
- Any model: comments on the models your application lists, checked at compile time
- Users and guests: a guest's email address never reaches JSON
- Threads: a whole thread in one query, a depth limit like Reddit's, sorting by oldest, newest or best
- Moderation: pending, approved, spam and rejected, with automatic approval by a setting or your own rule
- Safe removal: a comment with replies leaves a placeholder, and edits keep the previous text
- Reactions: likes and any reactions you allow, one of each per user, even under concurrent requests
- Mentions, counts, rate limits, Markdown and events for every change, with broadcasting
- Tested on SQLite, PostgreSQL and MySQL, including concurrent likes and replies
Installation
[dependencies]
laravel-comments = "0.3"
Quick start
let comment = Comment::post(post, Author::user(&user), "Great post!").await?;
let reply = comment.reply(Author::user(&user), "Thanks!").await?;
let page = Comment::threads(post)
.sort(Sort::Best)
.depth(3)
.get()
.await?;
Setup, moderation, reactions, policies and drawing the UI are covered in the README on GitHub.