Important
This guide outlines the steps to upgrade the package to the next major version, which includes breaking changes. Please follow the instructions carefully to avoid any critical issues during the process.
This version marks a significant leap from v1, introducing many useful features. However, it also includes notable breaking changes.
The primary change lies in the migrations. This version creates a new migration for the guests table and removes the
guest-related columns (guest_name, guest_email, ip_address) from the comments table and user_id removed from
reactions and added owner morph column (owner_id, owner_type) instead. While manually migrating data can
be cumbersome, there's no need to go through that hassle. An upgrade command has been introduced in the latest v1
release. Simply follow the steps below to complete the upgrade.
Update the package to its latest v1 release or at least version 1.5.*.
composer update lakm/laravel-comments:^1.5php artisan commenter:upgradeYou will receive a success message, then proceed to sep 4.
Change the commenter version constraint in composer.json
{
"require": {
"lakm/laravel-comments": "^2.0"
}
}Run following command
composer update lakm/laravel-comments:^2.0[!optional] Remove the previous assets by deleting
buildfolder inpublic/vendor/lakm/laravel-commentspath to free up space
php artisan vendor:publish --tag=comments-assets --forceEnjoy the v2 🤩.
This version fix the css style conflicting issue by adding a class prefix. So you must republish styles using below command.
php artisan vendor:publish --tag=comments-assets --forceImportant
Upgrading to v3 may feel a bit cumbersome due to the major changes introduced in this release. However, we’ve dedicated significant time and effort to ensure these updates improve the package for the long term. We apologize for any inconvenience 🙏, but we truly believe these changes will greatly enhance the package’s functionality and maintainability.
v3 introduces significant changes to the package that will break the existing version if upgraded. Please carefully follow the guide below before upgrading.
Following tables have changed their structures.
commentstablereply_idcolumn has been removed ❌.replymorph column has been added ✅.
- $table->unsignedBigInteger('reply_id')->nullable()->index(); + $table->nullableMorphs('reply');
This adds an additional reply_type column, so you’ll need to add that column and update the morph type of existing records in your comments table.
Important
The class namespace has changed ([refer]). Therefore, you must update the following morph types in your existing table records—unless you’re using morph maps.
| Table | Column | Old Morph Type | New Morph Type |
|---|---|---|---|
| comments | reply_type | - | LakM\Commenter\Models\Comment |
| comments (guest mode only) | commenter_type | LakM\Comments\Models\Guest | LakM\Commenter\Models\Guest |
| reactions (guest mode only) | owner_type | LakM\Comments\Models\Guest | LakM\Commenter\Models\Guest |
The package namespace has been changed from LakM\Comments to LakM\Commenter.
You have to change your existing code to use the new namespace. specially in Commentable Model and Commenter Model refer
The asset directives have been changed. New directives are as follows:
@commenterStyles
@commenterScriptsRefer docs for more details.
The blade directive namespace has been changed from comments to commenter.
So you have to use new directive namespace
ex:
<x-comments::index :model="$post" /> ❌
<x-commenter::index :model="$post" /> ✅Refer docs for more details.
Classes 've been grouped into relevant directories. As instance comment related events are now in the Comment directory.
You may have to change namespace to match the new structure.
- config file is now
commenter.phpunder commenter namespace in publishable assets. - All the other publishable assets including Assets, Views are published to
vendor/lakm/commenterdirectory.
v3 introduces significant changes that will break the existing version if upgraded. Do followings before upgrade to v3 from v2.
2️⃣ Undo the step 3 and all the steps in usage section
3️⃣ Remove the v2
4️⃣ Reinstall and set up the package as instructed in v3 installation section and usage section
This version adds pin message features. In order to support that, some breaking changes have been made.
is_pinnedcolumn has been added tocommentstable.
{
"require": {
"lakm/laravel-comments": "^4.0"
}
}Run following command
composer update lakm/laravel-comments:^4.0Run commenter install command to automatically take care of the changes.