---
title: "The Comments facade — Comments for Laravel | Roundly"
description: "The whole API in one place — a fluent write builder, edits, moderation, site-wide and scoped queries, locks, transfers, a blocklist check and fake()."
url: https://roundly-consulting.com/open-source/docs/comments-for-laravel/facade
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Comments for Laravel](https://roundly-consulting.com/open-source/docs/comments-for-laravel.md)

# The Comments facade

Comments — RoundlyConsulting\\Comments\\Facades\\Comments — is the whole API in one place. Writes start from a fluent builder that reads like a sentence; reads start from a query:

```php
use RoundlyConsulting\Comments\Facades\Comments;

// Write — a fluent builder, or a typed DTO
$comment = Comments::on($post)->as($user)->body('Nice write-up!')->post();
Comments::write($writeCommentData);

// Edit and moderate
Comments::update($comment, 'Edited body');
Comments::delete($comment);
Comments::restore($comment);
Comments::approve($comment);
Comments::hide($comment);

// Read — site-wide, per subject or per author
Comments::query()->pending()->mostReported()->paginate();
Comments::for($post)->visible()->rootsOnly()->withReplies()->get();
Comments::byAuthor($user)->get();

// Lock a subject, or the thread under one comment
Comments::lock($post);         Comments::unlock($post);         Comments::isLocked($post);
Comments::lockThread($comment); Comments::unlockThread($comment); Comments::isThreadLocked($reply);

// Move a discussion when two records merge; ask the blocklist about a body
Comments::transfer($duplicate, $original);
Comments::blocklisted($body);
```

| Comments::… | Returns | Does |
| --- | --- | --- |
| `on($subject)` | `CommentBuilder` | Start a comment: as(), body(), visible(), reply(), meta(), post(). |
| `write(WriteCommentData $data)` | `Comment` | Write from a typed DTO. |
| `update($comment, $body)` | `Comment` | Edit the body. |
| `delete($comment) / restore($comment)` | `void / Comment` | Soft-delete and restore. |
| `approve($comment) / hide($comment)` | `Comment` | Moderate. |
| `query()` | `CommentQuery` | Site-wide read and moderation query — every subject. |
| `for($subject) / byAuthor($author)` | `CommentQuery` | The same query, scoped to a subject or an author. |
| `lock($subject) / unlock($subject) / isLocked($subject)` | `CommentLock / void / bool` | Lock a whole subject. |
| `lockThread($comment) / unlockThread($comment) / isThreadLocked($comment)` | `Comment / Comment / bool` | Lock the thread under a comment. |
| `transfer($from, $to)` | `int` | Move every comment of one subject onto another; returns how many moved. |
| `blocklisted($body)` | `bool` | Whether a body matches the blocklist — checked as a write checks it, never rejecting. |
| `fake()` | `CommentsFake` | Record every mutation in tests — see Testing. |

## Builders

- Comments::on($subject) returns a CommentBuilder — as(), body(), visible(), reply(), meta(), then post(). The subject is a scope: a reply to another subject’s comment throws InvalidCommentParentException.
- Comments::query(), for($subject) and byAuthor($author) return a CommentQuery — filters (metadata included), ordering, get() / paginate() / count() and the bulk approveAll() / hideAll() / deleteAll(). Build it through the facade or the manager: its bulk terminals run through the manager.

## Model shorthands

$user->writeComment() and $comment->lockReplies() / unlockReplies() are sugar over the same manager, so behaviour, events and Comments::fake() are identical whichever form you use.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/comments-for-laravel.md)
