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

v2.0.0(1mo ago)184MITPHPPHP ^8.2|^8.3|^8.4|^8.5CI passing

Since Apr 28Pushed 1mo 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 2w ago

READMEChangelog (3)Dependencies (8)Versions (4)Used By (0)

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

[](#laravel-comments)

Comments package for Laravel.

Requirements
------------

[](#requirements)

- PHP 8.2, 8.3, 8.4 or 8.5
- Laravel 11, 12 or 13

> `2.x` targets Laravel 11/12/13 and PHP 8.2–8.5. Support for PHP 8.1 has been dropped; if you are still on PHP 8.1, stay on the `1.x` release line.

### 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()->today()->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

48

—

FairBetter than 94% of packages

Maintenance90

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~580 days

Total

3

Last Release

45d ago

Major Versions

v1.1.0 → v2.0.02026-07-02

PHP version history (2 changes)v1.0.0PHP ^8.0|^8.1|^8.2

v2.0.0PHP ^8.2|^8.3|^8.4|^8.5

### 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 (6 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

[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[tomshaw/electricgrid

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

119.8k](/packages/tomshaw-electricgrid)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)

PHPackages © 2026

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