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

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

nazaryuzhyn/laravel-comments
============================

Comments to Laravel application

v1.1.0(3y ago)229MITPHPPHP ^8.0|^8.1|^8.2

Since Apr 28Pushed 3y ago1 watchersCompare

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

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

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

[](#laravel-comments)

Comments package for Laravel.

### Features

[](#features)

- Simple package to use and install
- Creating Comments
- Approving Comments
- Auto Approve Comments
- Retrieving Comments

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

[](#installation)

You can install the package via composer:

```
composer require nazaryuzhyn/laravel-comments

```

### Publish Migration

[](#publish-migration)

Add migration to your project:

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

```

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

```
php artisan migrate

```

### Publish Package Configs

[](#publish-package-configs)

In your terminal type:

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

```

This command that will be published file with config `config/comments.php`.

See the [full configuration file](https://github.com/nazaryuzhyn/laravel-comments/blob/main/config/comments.php)for more information.

### Register the Package

[](#register-the-package)

Register package service provider in `providers` array inside `config/app.php`

```
'providers' => [
    // ...

    'Comments\CommentsServiceProvider',

],
```

Usage
-----

[](#usage)

### Enable package in models

[](#enable-package-in-models)

To let your models be able to receive comments, add the `Comments\Traits\Commentable` trait to the model

```
namespace App\Models;

use Comments\Traits\Commentable;
use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    use Commentable;

    // ...
}
```

### Creating Comments

[](#creating-comments)

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

```
$article = Article::find(1);

$comment = $article->comment('This is a comment...');
```

The comment method returns the newly created comment class.

Sometimes you may also want to create comments on behalf of other users. You can do this using the `commentFromUser` method and pass your user model to be bound with this comment:

```
$user = User::find(1);

$article = Article::find(1);

$comment = $article->commentFromUser($user, 'This is a comment from someone else.');
```

### Approving Comments

[](#approving-comments)

By default, all comments that you create are not approved.

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

```
$article = Article::find(1);

$comment = $article->comments->first();

$comment->approve();
```

### Auto Approve Comments

[](#auto-approve-comments)

If you want to approve a comment for a specific user automatically you can let your model implement the following interface and property:

```
namespace App\Models;

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

class User extends Authenticatable implements Commentator
{
    use Commenting;

    protected bool $autoCommentApproval = true;

    // ...
}
```

The autoCommentApproval property is intended to specify whether comments should be automatically approved, and you can either return true to mark the comment as approved or false to mark the comment as unapproved.

### Retrieving Comments

[](#retrieving-comments)

The models that use the `Commentable` trait have access to its comments using the `comments` relation:

```
$article = Article::find(1);

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

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

// Retrieve only disapproved comments
$disapproved = $article->comments()->disapproved()->get();

// Retrieve only for today comments
$commentsForToday = $article->comments()->forToday()->get();

// Retrieve only before today comments
$commentsBeforeToday = $article->comments()->beforeToday()->get();
```

### Testing

[](#testing)

```
composer test

```

### Changelog

[](#changelog)

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

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~0 days

Total

2

Last Release

1115d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/387d699256f9d5bca43548852a04459b1f096f0c1ef3d1751d447af71f3f1d33?d=identicon)[nazaryuzhyn](/maintainers/nazaryuzhyn)

---

Top Contributors

[![nazaryuzhyn](https://avatars.githubusercontent.com/u/37119070?v=4)](https://github.com/nazaryuzhyn "nazaryuzhyn (3 commits)")

---

Tags

laravelcommentslaravel-comments

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[beyondcode/laravel-comments

Add comments to your Laravel application

605414.2k2](/packages/beyondcode-laravel-comments)[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 ...

1194.7k](/packages/tizis-lara-comments)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

116.6k](/packages/tomshaw-electricgrid)[fbf/laravel-comments

A Laravel 4 package for adding commenting to a website that has user accounts

204.6k](/packages/fbf-laravel-comments)

PHPackages © 2026

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