PHPackages                             editmode/laravel-comments - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. editmode/laravel-comments

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

editmode/laravel-comments
=========================

This is my package laravel-comments

1.0.0(11mo ago)00[4 PRs](https://github.com/editmode/laravel-comments/pulls)MITPHPPHP ^8.4CI passing

Since Jun 22Pushed 1mo agoCompare

[ Source](https://github.com/editmode/laravel-comments)[ Packagist](https://packagist.org/packages/editmode/laravel-comments)[ Docs](https://github.com/editmode/laravel-comments)[ GitHub Sponsors](https://github.com/Nika)[ RSS](/packages/editmode-laravel-comments/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (6)Used By (0)

Laravel Comments
================

[](#laravel-comments)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f18b9ee0a0ff13f569b7207e647892610073e4b5ee57181f08dfca666654e689/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656469746d6f64652f6c61726176656c2d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/editmode/laravel-comments)[![Total Downloads](https://camo.githubusercontent.com/1f4ab81ce8b509f03d32eb9964c9bf1eb39031fad7e4bca611dfedab4a83d980/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656469746d6f64652f6c61726176656c2d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/editmode/laravel-comments)

A customizable Laravel package to easily add comments and threaded discussions to any model — ideal for blog posts, user profiles, product reviews, or any other entity in your app.

Supports optional like/dislike reactions, nested replies, and is designed to integrate smoothly with Inertia/React or Blade.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Quickstart](#quickstart)
- [Config](#config)
- [Like/Dislike Feature](#likedislike-feature)
- [Migrations](#migrations)
- [Routes](#routes)
- [Development Tips](#development-tips)
- [Testing](#testing)
- [Changelog](#changelog)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require editmode/laravel-comments
```

Quickstart
----------

[](#quickstart)

After installing the package, it's recommended that you create your own custom `Comment` model that extends the base model provided by the package. This gives you full flexibility to modify, extend, or customize comment behavior as needed.

### 1. Install the package

[](#1-install-the-package)

```
composer require editmode/laravel-comments
```

### 2. Publish the configuration file (optional but recommended):

[](#2-publish-the-configuration-file-optional-but-recommended)

```
php artisan vendor:publish --tag=comments-config
```

### 2.5. Publish the migrations

[](#25-publish-the-migrations)

The package includes migrations to create the comments and comment reactions tables.
You should publish them using:

```
php artisan vendor:publish --tag="comments-migrations"
```

> 🛑 **Important:** If you plan to use the like/dislike feature, make sure to also publish the config file first and enable it in `config/comments.php` by setting `like_dislike_feature` to `true`. Otherwise, the `comment_reactions` table will not be created during migration.

### 3. Create your own Comment model by extending the base comment model:

[](#3-create-your-own-comment-model-by-extending-the-base-comment-model)

> 🚨 **VERY IMPORTANT**
> For Laravel's polymorphic relationships to work *automatically* without manual configuration, your custom model **must** be named `Comment`. If you use any other name (like `UserComment`, `PostComment`, etc.), morph types like `commentable_type` will not resolve correctly unless you manually configure a morph map. Laravel automatically handles this when your model is named `Comment`.

```
use Nika\LaravelComments\Models\Comment as BaseComment;

class Comment extends BaseComment
         ↑
{
    // Add your own relationships, scopes, or overrides here
}
```

### 4. Update your configuration file `config/comments.php` to use your custom Comment model:

[](#4-update-your-configuration-file-configcommentsphp-to-use-your-custom-comment-model)

```
return [
    'model' => App\Models\Comment::class,
];
```

This setup allows you to fully control how comments behave in your application while leveraging the core features provided by the package.

---

### 5. Attach a comment to a model

[](#5-attach-a-comment-to-a-model)

You can now attach comments to any model by using the `HasComments` trait on that model.

```
use Nika\LaravelComments\Traits\HasComments;

class Post extends Model
{
    use HasComments;
}
```

Then, to add a comment as the currently authenticated user:

```
$post = Post::find(1);

$post->comment('This is a comment from the logged-in user');
```

Or explicitly pass a user:

```
$post->commentAsUser($user, 'This is a comment from a specific user');
```

This allows you to associate comments with any model that uses the `HasComments` trait.

Config
------

[](#config)

You can publish the config file with:

```
php artisan vendor:publish --tag="comments-config"
```

### Like/Dislike Feature

[](#likedislike-feature)

You can optionally enable the **like/dislike** feature in the package **config**. To enable this feature:

1. Set `like_dislike_feature` to `true` in `config/comments.php`.
2. Add the `HasReactions` trait to your custom comment model.

```
use Nika\LaravelComments\Models\Comment as BaseComment;
use Nika\LaravelComments\Traits\HasReactions;

class Comment extends BaseComment
{
    use HasReactions;
}
```

Migrations
----------

[](#migrations)

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="Nika\LaravelComments\LaravelCommentsServiceProvider" --tag="comments-migrations"
```

Then run the migrations:

```
php artisan migrate
```

> ⚠️ The `create_comment_reactions_table` migration will be skipped unless the `like_dislike_feature` setting is enabled in your `config/comments.php` file. If you plan to use the like/dislike feature, make sure to publish the **config** first and set `like_dislike_feature`to true before running `php artisan migrate`.

Routes
------

[](#routes)

You can register the package's routes by calling the macro in your `routes/web.php`:

```
Route::comments();
```

This will automatically register routes like `GET /comments`, and if the like/dislike feature is enabled, also `POST /comments/{comment}/react/{type}` — where `{type}` must be either `like` or `dislike`.

By default, routes are prefixed with `/comments`. You can change this by passing a different base URL to `Route::comments('your-prefix')`.

> 💡 See [Development Tips](#development-tips) for filtering the route list.

### Published Routes:

[](#published-routes)

MethodURIName**GET**`/{prefix}`—**POST**`/{prefix}`comment.store**PATCH**`/{prefix}/{comment}`comment.update**DELETE**`/{prefix}/{comment}`comment.destroy**POST**`/{prefix}/{comment}/react/{type}`comment.reaction.toggleDevelopment Tips
----------------

[](#development-tips)

### Filtering Routes

[](#filtering-routes)

To list only the routes registered by this package:

```
php artisan route:list --path=comments
```

This helps when debugging or inspecting how the package integrates into your app.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Nika](https://github.com/editmode)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance74

Regular maintenance activity

Popularity0

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

330d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e623919438332e7e2f82dc02ecf1117e4ad74b643fb9e087f9de45c8b9d8980b?d=identicon)[editmode](/maintainers/editmode)

---

Top Contributors

[![editmode](https://avatars.githubusercontent.com/u/62150609?v=4)](https://github.com/editmode "editmode (24 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

laravellaravel-commentsNika

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/editmode-laravel-comments/health.svg)

```
[![Health](https://phpackages.com/badges/editmode-laravel-comments/health.svg)](https://phpackages.com/packages/editmode-laravel-comments)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
