In extension, I want comments automatically created by a specific user to be marked as flag for moderation purposes.
Currently, I create comments using CommentPost::reply
and can set the is_approved
status directly. However, I want the comment to appear as flagged so it can be reviewed by the moderation team.
Here is a code snippet:
public function handle(Agent $agent): void
{
$reply = $agent->repliesTo($this->discussion);
// If the response is a CommentPost, set it as unapproved
if ($reply instanceof CommentPost) {
$reply->is_approved = false; // Mark as unapproved
$reply->save();
}
}
How can I programmatically mark a CommentPost
as flag?
Any guidance or examples would be greatly appreciated. Thank you!