Installation
Require the package, then publish and run its migrations. The service provider is auto-discovered — no manual registration:
composer require roundly-consulting/comments-for-laravel
php artisan vendor:publish --tag="comments-migrations"
php artisan migrateMigrations are publish-only — nothing is loaded from the package, so without the publish step php artisan migrate will not create the tables. The publish copies three migrations, each stamped with the publish time: create_comments_table, which creates the comments, comment_mentions and comment_locks tables, add_meta_to_comments_table, which adds the nullable meta column (see Comment metadata), and create_comment_revisions_table, which creates the comment_revisions table for the edit history (see Editing, deleting & restoring). A file you already published is recognised by its content, so republishing with --force overwrites that same file instead of adding a second copy.
If the models you comment on use UUID or ULID keys, set COMMENTS_KEY_TYPE before you migrate — see Configuration.
Sibling package tables
Likes, Reports, Approvals and Media Library for Laravel are pulled in as hard dependencies and ship their own migrations. Publish and run them too, so comment likes, reports and attachments have somewhere to live:
php artisan vendor:publish --tag="likes-migrations"
php artisan vendor:publish --tag="reports-migrations"
php artisan vendor:publish --tag="approvals-migrations"
php artisan vendor:publish --tag="media-migrations"
php artisan migrateUpgrading from 1.0
1.1.0 adds one migration, for the meta column. Publish the migrations again and migrate:
php artisan vendor:publish --tag="comments-migrations"
php artisan migrateYour published create_comments_table is recognised by its content and left where it is; only add_meta_to_comments_table is added, with a newer timestamp. If you edited your published copy of create_comments_table, the publisher no longer recognises it and adds a second copy — delete that one before you migrate. Until you migrate, everything that doesn’t use meta keeps working: a comment written without metadata never names the column.
Upgrading to 1.2
1.2.0 adds no migration. CommentResource’s author.type is now the author’s class basename (User), never the stored actor_type — on an app without a morph map that was the full class name (App\Models\User), handed to every API client. Clients that matched on the old value need updating; to render a different author shape, swap comments.resources.author — see API resources.
Upgrading to 2.1
2.1.0 adds one migration, create_comment_revisions_table, for the opt-in edit history. It is additive — a new table, nothing in the shipped tables changes. Publish the migrations again and migrate:
php artisan vendor:publish --tag="comments-migrations"
php artisan migrateEverything new is off by default: edit_history is false and deleted_comments is remove, so edits and deletes behave exactly as in 2.0 until you switch them on. Comments::update() gains an optional third argument, editor, and UpdateCommentData an optional editor — existing calls keep working.
Config & translations
The config file is optional — every key has a default. Publish it only to override. The messages ship in English and Slovak and load under the comments:: namespace without publishing — publish the language files only to reword them or add another language:
php artisan vendor:publish --tag="comments-config"
php artisan vendor:publish --tag="comments-translations"The package exposes three publish tags: comments-migrations, comments-config and comments-translations.
Check the active setup
The package reports its active configuration to Laravel’s about command — model, approval, length and depth limits, blocklist size (a count, never the terms), authorization, the edit-history switch, the deleted-comments mode, auto-moderation and inline media:
php artisan about --only=commentsShow 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 cryptoBy donating, you agree to our donation terms.
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.