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

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

quickcamx/laravel-comments
==========================

Add comments to your Laravel application

1.1.0(5y ago)0203MITPHPPHP ^7.2.5

Since Dec 30Pushed 2y agoCompare

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

READMEChangelogDependencies (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/b8b3a2441445e478c99fcc5f182ca322f7ebe44401ca585dea45b8fb35227170/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f717569636b63616d782f6c61726176656c2d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/quickcamx/laravel-comments)[![Build Status](https://camo.githubusercontent.com/cc458ba97528b97fad71371100c598899fefee728bd92fa8f1ab7d0b85beabe2/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f717569636b63616d782f6c61726176656c2d636f6d6d656e74732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/quickcamx/laravel-comments)[![Quality Score](https://camo.githubusercontent.com/58b53af0943027b396e7fcf4ce685f3a235d78431f38daa44cff45a96349cbfb/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f717569636b63616d782f6c61726176656c2d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/quickcamx-Technologies/laravel-comments)[![Total Downloads](https://camo.githubusercontent.com/fffe1444ed6aacbbbe236c6a20cf0e83f5834cc23b058ae7a5cf9e425460970a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f717569636b63616d782f6c61726176656c2d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/quickcamx/laravel-comments)

Add the ability to associate comments to your Laravel Eloquent models. The comments can be approved and nested. Read Article on quickcamx 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 quickcamx/laravel-comments
```

The package will automatically register itself.

You can publish the migration with:

```
php artisan vendor:publish --provider="quickcamx\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="quickcamx\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 quickcamx\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 quickcamx\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

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

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

1957d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/729ee3de07c8fc47504849f0f903db773417eca49c6e053443947852ba301dbc?d=identicon)[quickcamx](/maintainers/quickcamx)

---

Top Contributors

[![quickcamx](https://avatars.githubusercontent.com/u/61870992?v=4)](https://github.com/quickcamx "quickcamx (7 commits)")[![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/quickcamx-laravel-comments/health.svg)

```
[![Health](https://phpackages.com/badges/quickcamx-laravel-comments/health.svg)](https://phpackages.com/packages/quickcamx-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)[fbf/laravel-comments

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

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

PHPackages © 2026

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