PHPackages                             karabinse/laravel-commentable - 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. karabinse/laravel-commentable

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

karabinse/laravel-commentable
=============================

Easily add a commentable trait to a Eloquent model

1.1.0(1mo ago)03.7k↓85.5%MITPHPPHP ^8.2CI failing

Since Oct 30Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/KarabinSE/laravel-commentable)[ Packagist](https://packagist.org/packages/karabinse/laravel-commentable)[ Docs](https://github.com/karabinse/laravel-commentable)[ GitHub Sponsors](https://github.com/Karabin)[ RSS](/packages/karabinse-laravel-commentable/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (4)Dependencies (18)Versions (5)Used By (0)

Easily add a commentable trait to a Eloquent model
==================================================

[](#easily-add-a-commentable-trait-to-a-eloquent-model)

[![Latest Version on Packagist](https://camo.githubusercontent.com/de649e5db3a054964d951d86b1cc4ced325780764c3c94ae33d85f53434e97f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b61726162696e73652f6c61726176656c2d636f6d6d656e7461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/karabinse/laravel-commentable)

Easily add a commentable trait to an Eloquent model

```
use Karabin\Commentable\Concerns\Commentable;

class Product extends Model
{
    use Commentable;

    protected $guarded = ['location'];
```

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

[](#installation)

You can install the package via composer:

```
composer require karabinse/laravel-commentable
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="laravel-commentable-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-commentable-config"
```

This is the contents of the published config file:

```
return [
    'models' => [
        'comment' => \Karabin\Commentable\Models\Comment::class,
    ],

    // Add models that have comments here
    'model_map' => [
    ],

    'data' => [
        'comment' => \Karabin\Commentable\Data\CommentData::class,
    ],
];
```

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="laravel-commentable-views"
```

Usage
-----

[](#usage)

Add the trait to the model you want to add comments to.

```
class Customer extends Model
{
    use Commentable, HasFactory;
```

Configure the model map. You can also provide a data transformer for the comment itself.

```
use App\Data\CommentData;
use App\Models\Customer;
use App\Models\Product;

return [
    'models' => [
        'comment' => \Karabin\Commentable\Models\Comment::class,
    ],

    // Add models that have comments here
    'model_map' => [
        'customers' => Customer::class,
        'products' => Product::class,
    ],

    'data' => [
        'comment' => CommentData::class,
    ],
];
```

Saving a new comment:

```
use Karabin\Commentable\Models\Comment;

$commentModel = new Comment;
$comment = $commentModel->storeComment(
    commenter: $request->user(),
    modelName: $modelName,
    modelId: $modelId,
    comment: $request->comment,
    parentId: $request->parent_id ?? null
);

return CommentData::from($comment)->wrap('data');
```

Getting comments:

```
$commentModel = new Comment;
$comments = $commentModel->getCommentsForModel($modelName, $modelId);

return response()->json(['data' => $comments]);
```

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [Albin N](https://github.com/nivv)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance94

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.8% 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 ~194 days

Total

4

Last Release

31d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/53842b68734249d1bd4581663ce93e12dd241047cbdc11c49065f294c0228d36?d=identicon)[Albin N](/maintainers/Albin%20N)

---

Top Contributors

[![nivv](https://avatars.githubusercontent.com/u/4033930?v=4)](https://github.com/nivv "nivv (9 commits)")[![cleanSumo](https://avatars.githubusercontent.com/u/41383171?v=4)](https://github.com/cleanSumo "cleanSumo (2 commits)")

---

Tags

laravellaravel-commentableKarabin

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/karabinse-laravel-commentable/health.svg)

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

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[danestves/laravel-polar

A package to easily integrate your Laravel application with Polar.sh

8120.4k](/packages/danestves-laravel-polar)

PHPackages © 2026

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