Soft-Deleted Comments
Meerkat can remove comments in two ways: restorable Control Panel deletion and database soft deletion.
#Tombstones vs soft delete
| Tombstone | Soft delete | |
|---|---|---|
| Set by | Control Panel deletion | Spam auto-deletion or model deletion |
| Default visibility | Hidden from {{ meerkat:comments }} and the public API. Descendants hidden too. |
Hidden from {{ meerkat:comments }} and the public API. |
| Restorable | Yes. The Restore Comment action clears the tombstone and restores the conversation. | Code can restore the model, but the Control Panel and web API cannot restore this state. |
| Show with | include_tombstones="true" (and optionally include_tombstone_replies="true") |
include_trashed="true" |
| Template flag | {{ is_removed }} |
{{ is_deleted }} |
Both options require view comments.
#Render a placeholder where a tombstone used to be
Include removed comments and check is_removed:
1{{ meerkat:comments include_tombstones="true" }}
2 {{ if is_removed }}
3 <article class="comment comment--removed">
4 <em>This comment was removed on {{ removed_at format="Y-m-d" }}.</em>
5 </article>
6 {{ else }}
7 <article id="comment-{{ id }}">
8 <header>
9 <strong>{{ author_name }}</strong>
10 <time>{{ created_at }}</time>
11 </header>
12 <div>{{ comment_html }}</div>
13 </article>
14 {{ /if }}
15{{ /meerkat:comments }}
1<s-meerkat:comments include_tombstones="true">
2 @if ($is_removed)
3 <article class="comment comment--removed">
4 <em>This comment was removed on {{ \Illuminate\Support\Carbon::parse((string) $removed_at)->format('Y-m-d') }}.</em>
5 </article>
6 @else
7 <article id="comment-{{ $id }}">
8 <header>
9 <strong>{{ $author_name }}</strong>
10 <time>{{ $created_at }}</time>
11 </header>
12 <div>{!! $comment_html !!}</div>
13 </article>
14 @endif
15</s-meerkat:comments>
Tombstones also include removed_at, removed_by, and removed_reason.
#Also show replies underneath a tombstone
To render replies to a removed comment, add the second flag:
1{{ meerkat:comments include_tombstones="true" include_tombstone_replies="true" }}
2 {{ if is_removed }}
3 <article class="comment comment--removed">
4 <em>{{ author_name }}'s comment was removed.</em>
5 </article>
6 {{ else }}
7 <article id="comment-{{ id }}">
8 <strong>{{ author_name }}</strong>
9 <div>{{ comment_html }}</div>
10 </article>
11 {{ /if }}
12
13 {{ if has_replies }}
14 <div class="replies">
15 {{ children }}
16 {{ partial:_comment }}
17 {{ /children }}
18 </div>
19 {{ /if }}
20{{ /meerkat:comments }}
1<s-meerkat:comments include_tombstones="true" include_tombstone_replies="true">
2 @if ($is_removed)
3 <article class="comment comment--removed">
4 <em>{{ $author_name }}'s comment was removed.</em>
5 </article>
6 @else
7 <article id="comment-{{ $id }}">
8 <strong>{{ $author_name }}</strong>
9 <div>{!! $comment_html !!}</div>
10 </article>
11 @endif
12
13 @if ($has_replies)
14 <div class="replies">
15 @foreach ($children as $child)
16 @include('comments.comment', ['comment' => $child])
17 @endforeach
18 </div>
19 @endif
20</s-meerkat:comments>
include_tombstone_replies has no effect without include_tombstones.
#Showing soft-deleted rows
include_trashed="true" includes soft-deleted rows for users with view comments. Use it for admin tools and audits:
1{{ meerkat:comments include_trashed="true" }}
2 {{ if is_deleted }}
3 <article class="comment comment--trashed">
4 <em>Trashed: {{ comment_html }}</em>
5 </article>
6 {{ else }}
7 <article>{{ comment_html }}</article>
8 {{ /if }}
9{{ /meerkat:comments }}
1<s-meerkat:comments include_trashed="true">
2 @if ($is_deleted)
3 <article class="comment comment--trashed">
4 <em>Trashed: {!! $comment_html !!}</em>
5 </article>
6 @else
7 <article>{!! $comment_html !!}</article>
8 @endif
9</s-meerkat:comments>
#Permanent deletion
Use Comments::forceDeleteComment(), meerkat:purge, or meerkat:forget-identity to permanently remove comments, revisions, and audit history. See identity and retention commands.