PHPackages                             zepson/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. zepson/laravel-comments

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

zepson/laravel-comments
=======================

Add comments to your Laravel application

1.1.0(5y ago)11093MITPHPPHP ^7.2.5

Since Dec 30Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Zepson-Tech/laravel-comments)[ Packagist](https://packagist.org/packages/zepson/laravel-comments)[ Docs](https://github.com/pro-cms/laravel-comments)[ RSS](/packages/zepson-laravel-comments/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Add comments to your Laravel application
========================================

[](#add-comments-to-your-laravel-application)

[![Latest Version on Packagist](https://camo.githubusercontent.com/06fa837c3638a1253cc593ffde58003755d5dd875e7ddb7db4127ed2af2a61e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a6570736f6e2f6c61726176656c2d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zepson/laravel-comments)[![Build Status](https://camo.githubusercontent.com/36d12d0fe798a97fb850dc0eeb9bb95b1b4cec7a62e55753accc7e66182df9f0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7a6570736f6e2f6c61726176656c2d636f6d6d656e74732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/zepson/laravel-comments)[![Quality Score](https://camo.githubusercontent.com/a06a0bb35ec1094740cb4c5bfe5ea44edbdd7ba7512bc430923a62d7b572e711/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7a6570736f6e2f6c61726176656c2d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Zepson-Technologies/laravel-comments)[![Total Downloads](https://camo.githubusercontent.com/374c149b1cbe601cb1c47ffdea5183104f7de0da3e11e6f03bace7956a4a3466/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a6570736f6e2f6c61726176656c2d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zepson/laravel-comments)

Add the ability to associate comments to your Laravel Eloquent models. The comments can be approved and nested. Read Article on zepson website

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

$post->comment('This is a comment');

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

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

[](#installation)

You can install the package via composer:

```
composer require zepson/laravel-comments
```

The package will automatically register itself.

You can publish the migration with:

```
php artisan vendor:publish --provider="zepson\Comments\CommentsServiceProvider" --tag="migrations"
```

After the migration has been published you can create the media-table by running the migrations:

```
php artisan migrate
```

You can publish the config-file with:

```
php artisan vendor:publish --provider="zepson\Comments\CommentsServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

### Registering Models

[](#registering-models)

To let your models be able to receive comments, add the `HasComments` trait to the model classes.

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use zepson\Comments\Traits\HasComments;

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

### Creating Comments

[](#creating-comments)

To create a comment on your commentable models, you can use the `comment` method. It receives the string of the comment that you want to store.

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

$comment = $post->comment('This is a comment from a user.');
```

The comment method returns the newly created comment class.

Sometimes you also might want to create comments on behalf of other users. You can do this using the `commentAsUser` method and pass in your user model that should get associated with this comment:

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

$comment = $post->commentAsUser($yourUser, 'This is a comment from someone else.');
```

### Approving Comments

[](#approving-comments)

By default, all comments that you create are not approved - this is just a boolean flag called `is_approved` that you can use in your views/controllers to filter out comments that you might not yet want to display.

To approve a single comment, you may use the `approve` method on the Comment model like this:

```
$post = Post::find(1);
$comment = $post->comments->first();

$comment->approve();
```

### Auto Approve Comments

[](#auto-approve-comments)

If you want to automatically approve a comment for a specific user (and optionally model) you can let your User model implement the following interface and method:

```
namespace App\Models;

use zepson\Comments\Contracts\Commentator;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements Commentator
{
    /**
     * Check if a comment for a specific model needs to be approved.
     * @param mixed $model
     * @return bool
     */
    public function needsCommentApproval($model): bool
    {
        return false;
    }

}
```

The `needsCommentApproval` method received the model instance that you want to add a comment to and you can either return `true` to mark the comment as **not** approved, or return `false` to mark the comment as **approved**.

### Retrieving Comments

[](#retrieving-comments)

The models that use the `HasComments` trait have access to it's comments using the `comments` relation:

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

// Retrieve all comments
$comments = $post->comments;

// Retrieve only approved comments
$approved = $post->comments()->approved()->get();
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Novath Thomas](https://github.com/pro-cms)
- [Jofrey Abraham](https://github.com/abrahamjofrey)
- Beyond Code Team-Original Code

License
-------

[](#license)

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

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

1956d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0106b85cb7795defc0d17a630c94a97e9f9e33c6e8e433fe2bc340f40f444bc5?d=identicon)[zepson](/maintainers/zepson)

---

Top Contributors

[![pro-cms](https://avatars.githubusercontent.com/u/57701433?v=4)](https://github.com/pro-cms "pro-cms (4 commits)")

---

Tags

commentslaravel-commentszepson

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[beyondcode/laravel-comments

Add comments to your Laravel application

605414.2k2](/packages/beyondcode-laravel-comments)[usamamuneerchaudhary/commentify

Easy Laravel Livewire Comments with TailwindCSS UI

23214.3k](/packages/usamamuneerchaudhary-commentify)[tizis/lara-comments

Comments system for your Laravel application. Features: can be used to comment on any model, HTML filter customization (HTMLPurifier), API, comment rating, replies, events, auth rules ...

1204.7k](/packages/tizis-lara-comments)

PHPackages © 2026

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