PHPackages                             jobmetric/laravel-comment - 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. jobmetric/laravel-comment

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

jobmetric/laravel-comment
=========================

This is a comment management package for Laravel that you can use in your projects.

1.1.0(1y ago)5331MITPHPPHP &gt;=8.0.1

Since May 19Pushed 1y ago2 watchersCompare

[ Source](https://github.com/jobmetric/laravel-comment)[ Packagist](https://packagist.org/packages/jobmetric/laravel-comment)[ Docs](https://doc.jobmetric.net/package/laravel-comment)[ RSS](/packages/jobmetric-laravel-comment/feed)WikiDiscussions master Synced 1mo ago

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

[![Contributors](https://camo.githubusercontent.com/9578f7de6423de8d5fb916f0f51abd340a1e9b1d583404c02f92150bad50f7e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f6a6f626d65747269632f6c61726176656c2d636f6d6d656e742e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/jobmetric/laravel-comment/graphs/contributors)[![Forks](https://camo.githubusercontent.com/edfff208d35e9d59a9e9b86fed698915d9538a1b6695a48b79370e48caf7ffed/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6a6f626d65747269632f6c61726176656c2d636f6d6d656e742e7376673f7374796c653d666f722d7468652d6261646765266c6162656c3d466f726b)](https://github.com/jobmetric/laravel-comment/network/members)[![Stargazers](https://camo.githubusercontent.com/373f4803af24f2f5232f14eb07a556a0b56bc49ea8db34a88c8aac779943f0fa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6a6f626d65747269632f6c61726176656c2d636f6d6d656e742e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/jobmetric/laravel-comment/stargazers)[![MIT License](https://camo.githubusercontent.com/16fcf824757c40372ff958c0cb7c595158feb232f899127d29519590cf8f1d05/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a6f626d65747269632f6c61726176656c2d636f6d6d656e742e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/jobmetric/laravel-comment/blob/master/LICENCE.md)[![LinkedIn](https://camo.githubusercontent.com/eb590f47a3fca74584d18db8dd3e985ae3d786f50cd41b7530c3af3885da233c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d4c696e6b6564496e2d626c75652e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d6c696e6b6564696e26636f6c6f72423d353535)](https://linkedin.com/in/majidmohammadian)

Comment for laravel
===================

[](#comment-for-laravel)

This is a comment management package for any object in Laravel that you can use in your projects.

Install via composer
--------------------

[](#install-via-composer)

Run the following command to pull in the latest version:

```
composer require jobmetric/laravel-comment
```

Documentation
-------------

[](#documentation)

This package evolves every day under continuous development and integrates a diverse set of features. It's a must-have asset for Laravel enthusiasts and provides a seamless way to align your projects with basic comment models.

In this package, you can use it seamlessly with any model that needs comments.

Now let's go to the main function.

> #### Before doing anything, you must migrate after installing the package by composer.
>
> [](#before-doing-anything-you-must-migrate-after-installing-the-package-by-composer)

```
php artisan migrate
```

Meet the `HasComment` class, meticulously designed for integration into your model. This class automates essential tasks, ensuring a streamlined process for:

In the first step, you need to connect this class to your main model.

```
use JobMetric\Comment\HasComment;

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

When you add this class, you will have to implement `CommentContract` to your model.

```
use JobMetric\Comment\Contracts\CommentContract;

class Post extends Model implements CommentContract
{
    use HasComment;
}
```

Now you have to use the needsCommentApproval function, and you have to add it to your model.

```
use JobMetric\Comment\Contracts\CommentContract;

class Post extends Model implements CommentContract
{
    use HasComment;

    public function needsCommentApproval(): bool
    {
        return false;
    }
}
```

How is it used?
---------------

[](#how-is-it-used)

You can now use the `HasComment` class for your model.

#### Store comment

[](#store-comment)

You can store a new comment by using the following code:

```
$post = Post::create([
    'title' => 'Post title',
    'body' => 'Post body',
]);

$post->comment('This is a comment', $parent_comment_id, $user_id);
```

> If you want to store a comment without a parent comment, you can pass `null` to the second parameter.
>
> If you want to store a comment without a user, you can pass `null` to the third parameter.

#### Update comment

[](#update-comment)

You can update an existing comment by using the following code:

```
$post->updateComment($comment->id, 'This is a new comment');
```

#### Forget comment

[](#forget-comment)

You can forget an existing comment by using the following code:

```
$post->forgetComment($comment->id);
```

#### Forget all comments

[](#forget-all-comments)

You can forget all comments by using the following code:

```
$post->forgetComments();
```

#### Get comments

[](#get-comments)

You can get all comments by using the following code:

```
$comments = $post->comments;
```

#### Get approved comments

[](#get-approved-comments)

You can get all approved comments by using the following code:

```
$comments = $post->approvedComments;
```

#### Get unapproved comments

[](#get-unapproved-comments)

You can get all unapproved comments by using the following code:

```
$comments = $post->unapprovedComments;
```

#### Get parent comments

[](#get-parent-comments)

You can get all parent comments by using the following code:

```
$comments = $post->parentComments;
```

CanComment trait
----------------

[](#cancomment-trait)

You can also connect the `CanComment` trait class to your User model.

```
use JobMetric\Comment\CanComment;

class User extends Authenticatable
{
    use CanComment;
}
```

Events
------

[](#events)

This package contains several events for which you can write a listener as follows

EventDescription`CommentStoredEvent`This event is called after storing the comment.`CommentUpdateEvent`This event is called after updating the comment.`CommentForgetEvent`This event is called after forgetting the comment.Contributing
------------

[](#contributing)

Thank you for considering contributing to the Laravel Comment! The contribution guide can be found in the [CONTRIBUTING.md](https://github.com/jobmetric/laravel-comment/blob/master/CONTRIBUTING.md).

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/jobmetric/laravel-comment/blob/master/LICENCE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

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

Total

2

Last Release

693d ago

### Community

Maintainers

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

---

Top Contributors

[![MajidMohammadian](https://avatars.githubusercontent.com/u/2099965?v=4)](https://github.com/MajidMohammadian "MajidMohammadian (29 commits)")

---

Tags

commentlaravellaravel-commentlaravel-packagelaravelpackagemanagementcommentjobmetric

### Embed Badge

![Health badge](/badges/jobmetric-laravel-comment/health.svg)

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

###  Alternatives

[firefly-iii/data-importer

Firefly III Data Import Tool.

7545.8k](/packages/firefly-iii-data-importer)[cybercog/laravel-paket

Composer personal web interface. Manage Laravel dependencies without switching to command line!

1753.3k](/packages/cybercog-laravel-paket)

PHPackages © 2026

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