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.0.2(6mo ago)03.5k↓50%MITPHPPHP ^8.2CI passing

Since Oct 30Pushed 6mo 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 1mo ago

READMEChangelog (3)Dependencies (9)Versions (4)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

41

—

FairBetter than 89% of packages

Maintenance67

Regular maintenance activity

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~186 days

Total

3

Last Release

194d ago

### Community

Maintainers

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

---

Top Contributors

[![cleanSumo](https://avatars.githubusercontent.com/u/41383171?v=4)](https://github.com/cleanSumo "cleanSumo (2 commits)")[![nivv](https://avatars.githubusercontent.com/u/4033930?v=4)](https://github.com/nivv "nivv (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-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[tarfin-labs/event-machine

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

188.5k](/packages/tarfin-labs-event-machine)

PHPackages © 2026

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