GuidePremium
Reader comments in CoullWorks Blog for Laravel
How readers comment, how threads and paging work, what each field of the public form does, what happens to a comment in moderation, and which emails are sent and when.
Updated 16 November 2026Back to the package pageBuy
Comments are an optional module. This page follows a comment from the reader's side: the form, the thread, the checks that protect it, the moderation that decides whether it is shown, and the emails around it. Moderating in the admin is in Comments, and every limit has its own field in Settings, Comments.
Turn comments on#
- Set
coullworks-blog.comments.enabledtotrueinconfig/coullworks-blog.php. It is off by default, and while it is off no route, listener or extra of the module is registered. - Run the module's migrations:
php artisan vendor:publish --tag=cwb-comments-migrations, thenphp artisan migrate. - Open a published post. The section sits at the foot of the article.
The module has its own config keys: middleware (empty by default; add web to recognise signed-in readers, then exempt the comment routes from CSRF), guard (the guard that recognises a signed-in reader, null for the default), honeypot_field (cwb_website), token_ttl_minutes (1440), user_model (the host's user class, to anonymise a deleted user's comments), throttle (read, form_token and unsubscribe, each 60 a minute per address) and the Turnstile and reCAPTCHA url and secret entries. The secrets belong in the environment, never in the database. They are listed in the configuration reference.
Comment threads#

"Comments (4)" counts every approved comment, replies included. The first comment, from Dev Rao, has an indented reply from Maya Hartley with a blue Staff badge. Hannah Cole and Sam Whitlow are top-level comments with no replies. Each comment, replies included, has a Reply link. Below the thread is the Leave a comment form.
- Only approved comments show. A pending, rejected or spam comment is never shown to readers, and is not counted.
- Order. Top-level comments run oldest first. Each shows all its approved replies under it, indented.
- Depth. A reply can be answered, up to the setting Reply depth (
comments.max_depth, 1 to 3, default 3). Nothing deeper than three is possible. A reply can only be made to an approved comment. - Staff replies carry a Staff badge. They are written by a moderator in the admin.
- Paging. The thread shows a page of top-level comments at a time (
comments.threads_per_page, default 20), each with all its replies. Under the list, Older comments and Newer comments links move between pages, with "Page 2 of 3" between them. The page is thecpagequery on the post address. A page past the last shows the last page. Every page has the post address, withoutcpage, as its canonical address, so search engines do not index copies. A page costs at most four database queries, however long the thread is. - Empty. With no comments, the section says "Be the first to comment".
- Closed. A moderator can close comments on one post (the post editor's Comments tab), and the blog can close them automatically a number of days after publishing (
comments.close_after_days, 0 never). The form is then replaced by "Comments are closed", and sending a comment is refused with a 403. - Reply links. Every approved comment above the depth limit has a Reply link while comments are open. It reloads the page with
?reply=<id>, changes the form heading to "Reply to a comment" and adds a line "Replying to Dev Rao" with a Cancel reply link. The form then sends that comment's id asparent_id. A reply target that is not approved, is at the depth limit, or is on another page is ignored and the form posts a top-level comment.

The form after pressing Reply. Every comment in the thread carries its own Reply link.
The public form#

The Leave a comment form at the foot of the capture above: a Name field, an Email field labelled "optional, never shown", a Comment box, the checkbox "Email me when someone replies" and an orange Post comment button. The other fields in the table below are hidden and not visible here.
To comment, a reader fills the visible fields and presses Post comment. The page sends the comment with JavaScript (the form says "Comments need JavaScript to be sent" when it is off). These are the fields:
| Field | Visible | Required | Rule | What it does |
|---|---|---|---|---|
name | Yes, Name | Yes | Text, up to 255 characters | Shown with the comment |
email | Yes, Email | No | A valid address, up to 255 | Never shown. Used for reply emails and to anonymise by address later |
body | Yes, Comment | Yes | 2 characters at least, up to the setting Maximum comment length (comments.max_length, default 5000) | The comment. Control characters are removed; line breaks are kept |
notify_on_reply | Yes, "Email me when someone replies" | No | A tick | Asks for one email when the first reply to this comment is approved. Ignored when no email is given |
cwb_website (the honeypot) | Hidden off screen | No, must stay empty | Name set by comments.honeypot_field | A trap for bots. A comment with anything in it is refused |
time_token | Hidden | Yes | Issued by the page for this post | Proves the form was loaded. The comment is refused if it is sent faster than Minimum seconds to fill the form (default 3) or after the token's life (token_ttl_minutes, 1440) |
idempotency_key | Hidden | Yes | Up to 64 characters | Stops a double submit. Sending the same key again returns the first comment instead of creating another. May also come in an Idempotency-Key header |
verifier_token | Hidden, only with a verifier | When a verifier is set | Up to 4096 characters | The Cloudflare Turnstile or Google reCAPTCHA answer, when Verifier in settings is not none. The provider's own field names are accepted too |
parent_id | Set by the Reply link | No | The id of an approved comment | The comment being answered |
locale | Hidden | No | Letters, digits, dash, underscore, up to 12 | The language of the page the comment was written on. Defaults to the blog's default language |
post_id | Hidden | Yes | The post | Which post the comment belongs to |
The page fetches time_token and idempotency_key from the address {blog}/comments/form-token?post=ID as it loads, so a page held in a full-page cache still gets fresh ones. That address answers 403 while comments are closed.

A send with the name and comment left empty. A red box above the fields reads "The name field is required." and "The body field is required.". The thread above it is unchanged.
When a send fails, each message appears in the box above the fields, and each one that belongs to a field links to it. When it works, the form clears and a message says either "Thank you, your comment is published." (approved at once) or "Your comment is waiting for approval".
The checks, in order#
Each comment goes through these, and the first that fails refuses it:
- The honeypot is empty.
- The time token is valid and old enough.
- Links: a comment with more links than Links allowed in a comment (default 2) is refused.
- Rate: one visitor (by address, hashed, per post) may send Comments per window (default 1) in Rate window seconds (default 30), and Comments per hour (default 10). A refused attempt is given back and does not count.
- The verifier, when one is set. If the provider cannot be reached, Accept comments when the verifier is unavailable decides: off refuses the comment, on accepts it as pending.
- A listener of the
CommentSubmittingevent may refuse it (see the events reference).
Refusals answer 422 (guard, depth), 429 (rate) or 403 (closed, guests not allowed). Guests can comment unless Guests may comment is off.
What happens to a comment#

The admin Comments list on the Pending tab right after one comment was approved: a "Comment approved" notice at the top right, the tabs Pending 3, Approved 4, Spam 1, Rejected 0 and All 8, and two pending comments each with an Approve link.
- Stored as pending. Every new comment starts as pending and appears in the Pending tab. The reader sees "Your comment is waiting for approval". The exception is a signed-in reader when Approve signed-in readers automatically is on and the checks passed: that comment is approved at once. A comment accepted while the verifier was down is always pending.
- A moderator decides. Approve, reject or mark as spam, one by one or in bulk. See Comments. Only approving makes it public. Every change is recorded in the comment's history.
- Editing. A moderator can edit the text of a comment (never the author name). It keeps its status, and the edit is recorded.
- Deleting a person. To erase a commenter, run
php artisan cwb:comments-anonymise --email=reader@example.comor--user=42. The text stays, the name reads "Former commenter" and the email is cleared. If you setcomments.user_modelto your user class, deleting a user does this automatically.
Emails#
Two kinds of email are sent. Both are queued, so run a queue worker (see install). Set APP_URL, because the links in a queued mail use it.
To staff about a new comment#
Every address in Staff notification recipients (Settings, Comments) gets an email when a comment is submitted. The subject is "New comment waiting: pending" (or the status it was stored with), and the body names the commenter and the post and quotes up to 400 characters. Leave the field empty to send none.
To a commenter about a reply#
A commenter who gave an email and ticked Email me when someone replies gets one email, the first time a reply to their comment is approved. It is sent once per reply, so approving again never repeats it. No email is sent when the reply was written with the same address as the comment. The subject is "Someone replied to your comment". The body gives the replier's name and up to 400 characters of the reply. It ends with a link to stop these emails and carries the List-Unsubscribe and one-click List-Unsubscribe-Post headers, which Gmail and Yahoo expect.
Stopping reply emails#
The link in the mail opens a page titled "Stop reply emails" with a Stop these emails button. Opening the page changes nothing, so a mail scanner fetching the link does no harm. Pressing the button (or a mail client's one-click request) turns off emails for that one comment, and the next page says "You will not get further replies for this comment." Doing it twice is safe. The link is signed with APP_KEY, never expires and needs no table. A changed id or missing signature answers 403, and a comment that no longer exists answers 404. Rotating APP_KEY makes every older link answer 403. If you add the web middleware to the module routes, also exempt comments/unsubscribe/* from CSRF, or the one-click request fails with 419. The two pages can be restyled: see Views you can override.







