PHPackages                             jodeveloper/commentions - 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. jodeveloper/commentions

Abandoned → [kirschbaum-development/commentions](/?search=kirschbaum-development%2Fcommentions)Library[Utility &amp; Helpers](/categories/utility)

jodeveloper/commentions
=======================

A package to allow you to create comments, tag users and more

1.0.2(7mo ago)022MITPHP

Since Oct 9Pushed 7mo agoCompare

[ Source](https://github.com/JoDeveloper/commentions)[ Packagist](https://packagist.org/packages/jodeveloper/commentions)[ RSS](/packages/jodeveloper-commentions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (15)Versions (5)Used By (0)

[![](screenshots/commentions-logo.png)](screenshots/commentions-logo.png)

[![Laravel Supported Versions](https://camo.githubusercontent.com/4b685234c18c2a323630d28899a6df0f78314186029222a4483f21c9c9d9a506/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302e782f31312e782f31322e782d677265656e2e737667)](https://camo.githubusercontent.com/4b685234c18c2a323630d28899a6df0f78314186029222a4483f21c9c9d9a506/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302e782f31312e782f31322e782d677265656e2e737667)[![Filament Supported Versions](https://camo.githubusercontent.com/08c9c615562263fa33a0739721c01fed491eac14fe9ac5ca69cd0138de41363a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f66696c616d656e742d332e782f342e782d677265656e2e737667)](https://camo.githubusercontent.com/08c9c615562263fa33a0739721c01fed491eac14fe9ac5ca69cd0138de41363a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f66696c616d656e742d332e782f342e782d677265656e2e737667)[![CI](https://github.com/kirschbaum-development/commentions/actions/workflows/ci.yml/badge.svg)](https://github.com/kirschbaum-development/commentions/actions/workflows/ci.yml)[![MIT Licensed](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Latest Version on Packagist](https://camo.githubusercontent.com/e176550a612c0259985b5bf7295be3e9ea6d3d5039bbdfffde97679bb2fb970a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b69727363686261756d2d646576656c6f706d656e742f636f6d6d656e74696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kirschbaum-development/commentions)[![Total Downloads](https://camo.githubusercontent.com/5f24f2acaa414e0c5e3a073b69c6b5f419db6fd3b31ff869bcd8a16e2c6f37da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b69727363686261756d2d646576656c6f706d656e742f636f6d6d656e74696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kirschbaum-development/commentions)

This package is a form of [commentions](https://github.com/kirschbaum-development/commentions) made by [Mo Khosh](https://github.com/mokhosh). All credit goes to him.

This version just updates some files.

Commentions is a drop-in package for Filament that allows you to add comments to your resources. You can configure it so your users are mentionable in the comments, and it dispatches events so you can handle mentions in your own application however you like.

[![](screenshots/comments-demo.png)](screenshots/comments-demo.png)

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

[](#installation)

```
composer require jodeveloper/commentions
```

Usage
-----

[](#usage)

1. Publish the migrations

```
php artisan vendor:publish --tag="commentions-migrations"
```

2. In your `User` model implement the `Commenter` interface.

```
use Jodeveloper\\Commentions\Contracts\Commenter;

class User extends Model implements Commenter
{
    // ...
}
```

3. In the model you want to add comments, implement the `Commentable` interface and the `HasComments` trait.

```
use Jodeveloper\\Commentions\HasComments;
use Jodeveloper\\Commentions\Contracts\Commentable;

class Project extends Model implements Commentable
{
    use HasComments;
}
```

### Usage with Filament

[](#usage-with-filament)

There are a couple of ways to use Commentions with Filament.

1. Register the component in your Filament Infolists:

> This works for Filament 3 and 4.

```
    CommentsEntry::make('comments')
        ->mentionables(fn (Model $record) => User::all()),
```

If you wish to make the comments more distinct from the rest of the page, we recommend wrapping them in a `Section`.

For Filament 3:

```
\Filament\Infolists\Components\Section::make('Comments')
    ->schema([
        CommentsEntry::make('comments'),
    ]),
```

For Filament 4:

```
\Filament\Schemas\Components\Section::make('Comments')
    ->components([
        CommentsEntry::make('comments'),
    ]),
```

2. Or in your table actions:

If you are using Filament 3, you must use `CommentsTableAction` in your table's `actions` array:

```
use Jodeveloper\\Commentions\Filament\Actions\CommentsTableAction;

->actions([
    CommentsTableAction::make()
        ->mentionables(User::all())
])
```

If you are using Filament 4, you should use `CommentsAction` in `recordActions` instead:

```
use Jodeveloper\\Commentions\Filament\Actions\CommentsAction;

->recordActions([
    CommentsAction::make()
        ->mentionables(User::all())
])
```

3. Or as a header action:

> This works for Filament 3 and 4.

```
use Jodeveloper\\Commentions\Filament\Actions\CommentsAction;

protected function getHeaderActions(): array
{
    return [
        CommentsAction::make(),
    ];
}
```

### Subscription Management

[](#subscription-management)

Commentions includes a subscription system that allows users to subscribe to receive notifications when new comments are added to a commentable resource.

#### Subscription Actions

[](#subscription-actions)

You can add subscription actions to your Filament resources:

```
use Jodeveloper\\Commentions\Filament\Actions\SubscriptionAction;

// In header actions
protected function getHeaderActions(): array
{
    return [
        SubscriptionAction::make(),
    ];
}

// In table actions (Filament 3)
->actions([
    SubscriptionTableAction::make(),
])

// In record actions (Filament 4)
->recordActions([
    SubscriptionAction::make(),
])
```

#### Subscription Sidebar

[](#subscription-sidebar)

When using comments in modals, a subscription sidebar is automatically displayed showing:

- Subscribe/unsubscribe button for the current user
- List of users currently subscribed to the commentable
- Real-time updates when subscription status changes

##### Livewire options

[](#livewire-options)

When using the `commentions::comments` Livewire component directly, you can control the sidebar and its contents via component properties:

- `sidebarEnabled` (bool, default: true): toggles the entire subscription sidebar
- `showSubscribers` (bool, default: `config('commentions.subscriptions.show_subscribers', true)`): toggles the subscribers list within the sidebar

Examples:

```
// Hide the sidebar entirely

// Keep the sidebar, but hide the subscribers list (uses config default if omitted)

```

Inside the component/template you can also rely on these computed properties:

- `canSubscribe`: whether the current user can subscribe
- `isSubscribed`: whether the current user is subscribed to the current record
- `subscribers`: a collection of current subscribers

The component exposes a `toggleSubscription()` action which subscribes/unsubscribes the current user.

#### Disabling the Subscription Sidebar

[](#disabling-the-subscription-sidebar)

You can disable the subscription sidebar if you don't want subscription functionality:

```
use Jodeveloper\\Commentions\Filament\Actions\CommentsAction;

->recordActions([
    CommentsAction::make()
        ->mentionables(User::all())
        ->disableSidebar()
])
```

#### Subscription Methods

[](#subscription-methods)

The `HasComments` trait provides methods for managing subscriptions programmatically:

```
// Subscribe a user
$commentable->subscribe($user);

// Unsubscribe a user
$commentable->unsubscribe($user);

// Check if a user is subscribed
$isSubscribed = $commentable->isSubscribed($user);

// Get all subscribers
$subscribers = $commentable->getSubscribers();
```

---

### Configuration

[](#configuration)

You can publish the configuration file to make changes.

```
php artisan vendor:publish --tag="commentions-config"
```

#### Pagination (Filament)

[](#pagination-filament)

Commentions supports built-in pagination for the embedded list of comments and it is enabled by default. You can disable it or control the number of comments shown per page and per click.

- Enabled by default
- Disable via `disablePagination()`
- Configure page size
- Customize the load more label
- Control how many comments are appended per click (defaults to the page size)

Examples:

Default Usage:

```
use Jodeveloper\\Commentions\Filament\Actions\CommentsAction;

->recordActions([
    CommentsAction::make()
        ->mentionables(User::all())
        ->perPage(10)

])
```

Without Pagination:

```
use Jodeveloper\\Commentions\Filament\Actions\CommentsAction;

->recordActions([
    CommentsAction::make()
        ->mentionables(User::all())
        ->disablePagination();

])
```

Advanced Usage:

```
use Jodeveloper\\Commentions\Filament\Infolists\Components\CommentsEntry;

Infolists\Components\Section::make('Comments')
    ->schema([
        CommentsEntry::make('comments')
            ->mentionables(fn (Model $record) => User::all())
            ->perPage(8)
            ->loadMoreIncrementsBy(8)
            ->loadMoreLabel('Show older'),
    ])
```

When pagination is enabled, a "Show more" button is displayed to load additional comments incrementally.

#### Configuring the User model and the mentionables

[](#configuring-the-user-model-and-the-mentionables)

If your `User` model lives in a different namespace than `App\Models\User`, you can configure it in `config/commentions.php`:

```
    'commenter' => [
        'model' => \App\Domains\Users\User::class,
    ],
```

#### Configuring the Comment model

[](#configuring-the-comment-model)

If you need to customize the Comment model, you can extend the `\Jodeveloper\\Commentions\Comment` class and then update the `comment.model` option in your `config/commentions.php` file:

```
    'comment' => [
        'model' => \App\Models\Comment::class,
        // ...
    ],
```

#### Configuring Comment permissions

[](#configuring-comment-permissions)

By default, users can create comments, as well as edit and delete their own comments. You can adjust these permissions by implementing your own policy:

##### 1) Create a custom policy

[](#1-create-a-custom-policy)

```
namespace App\Policies;

use Jodeveloper\\Commentions\Comment;
use Jodeveloper\\Commentions\Contracts\Commenter;
use Jodeveloper\\Commentions\Policies\CommentPolicy as CommentionsPolicy;

class CommentPolicy extends CommentionsPolicy
{
    public function create(Commenter $user): bool
    {
        // TODO: Implement custom permission logic.
    }

    public function update($user, Comment $comment): bool
    {
        // TODO: Implement custom permission logic.
    }

    public function delete($user, Comment $comment): bool
    {
        // TODO: Implement custom permission logic.
    }
}
```

##### 2) Register your policy in the configuration file

[](#2-register-your-policy-in-the-configuration-file)

Update the `comment.policy` option in your `config/commentions.php` file:

```
    'comment' => [
        // ...
        'policy' => \App\Policies\CommentPolicy::class,
    ],
```

### Configuring the Commenter name

[](#configuring-the-commenter-name)

By default, the `name` property will be used to render the mention names. You can customize it either by implementing the Filament `HasName` interface OR by implementing the optional `getCommenterName` method.

```
use Filament\Models\Contracts\HasName;
use Jodeveloper\\Commentions\Contracts\Commenter;

class User extends Model implements Commenter, HasName
{
    public function getFilamentName(): string
    {
        return (string) '#' . $this->id . ' - ' . $this->name;
    }
}
```

```
use Jodeveloper\\Commentions\Contracts\Commenter;

class User extends Model implements Commenter
{
    public function getCommenterName(): string
    {
        return (string) '#' . $this->id . ' - ' . $this->name;
    }
}
```

### Configuring the Commenter avatar

[](#configuring-the-commenter-avatar)

To configure the avatar, make sure your User model implements Filament's `HasAvatar` interface.

```
use Filament\Models\Contracts\HasAvatar;

class User extends Authenticatable implements Commenter, HasName, HasAvatar
{
    public function getFilamentAvatarUrl(): ?string
    {
        return $this->avatar_url;
    }
}
```

### Translations

[](#translations)

You can publish the package translation files and override any strings used by the UI.

Publish the language files into your application:

```
php artisan vendor:publish --tag="commentions-lang"
``

This will copy the language files to:

- `lang/vendor/commentions/{locale}/comments.php`

Override only the keys you need. Example (English):

```php
// lang/vendor/commentions/en/comments.php
return [
    'label' => 'Notes',
    'no_comments_yet' => 'No notes yet.',
    'add_reaction' => 'Add a reaction',
    'cancel' => 'Close',
    'delete' => 'Remove',
    'save' => 'Update',
];
```

### Events

[](#events)

Events are dispatched when a comment is created, reacted to, or when users are mentioned or subscribed:

- `Jodeveloper\\Commentions\Events\UserWasMentionedEvent`
- `Jodeveloper\\Commentions\Events\UserIsSubscribedToCommentableEvent`
- `Jodeveloper\\Commentions\Events\CommentWasCreatedEvent`
- `Jodeveloper\\Commentions\Events\CommentWasReactedEvent`

#### Subscription Events

[](#subscription-events)

When a new comment is created, all subscribed users receive notifications through the `UserIsSubscribedToCommentableEvent`. You can listen to this event to send custom notifications:

```
namespace App\Listeners;

use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Notifications\NewCommentNotification;
use Jodeveloper\\Commentions\Events\UserIsSubscribedToCommentableEvent;

class SendSubscribedUserNotification implements ShouldQueue
{
    use InteractsWithQueue;

    public function handle(UserIsSubscribedToCommentableEvent $event): void
    {
        $event->user->notify(
            new NewCommentNotification($event->comment)
        );
    }
}
```

### Sending notifications when a user is mentioned

[](#sending-notifications-when-a-user-is-mentioned)

Every time a user is mentioned, the `Jodeveloper\\Commentions\Events\UserWasMentionedEvent` is dispatched. Commentions ships an optional, opt-in notification you can enable via configuration, or you can listen to the event and handle it yourself.

Example usage:

```
namespace App\Listeners;

use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Notifications\UserMentionedInCommentNotification;
use Jodeveloper\\Commentions\Events\UserWasMentionedEvent;

class SendUserMentionedNotification implements ShouldQueue
{
    use InteractsWithQueue;

    public function handle(UserWasMentionedEvent $event): void
    {
        $event->user->notify(
            new UserMentionedInCommentNotification($event->comment)
        );
    }
}
```

If you have [event auto-discovery](https://laravel.com/docs/11.x/events#registering-events-and-listeners), this should be enough. Otherwise, make sure to register your listener on the `EventServiceProvider`.

#### Built-in opt-in notifications

[](#built-in-opt-in-notifications)

Enable notifications for mentions in your `config/commentions.php`:

```
    'notifications' => [
        'mentions' => [
            'enabled' => true,
            'channels' => ['mail', 'database'],
        ],
    ],
```

Optionally, provide a URL resolver so emails/links point users to the right place:

```
use Jodeveloper\\Commentions\Config;

Config::resolveCommentUrlUsing(function (\Jodeveloper\\Commentions\Comment $comment) {
    // Return a URL to view the record and scroll to the comment
    return route('projects.show', $comment->commentable) . '#comment-' . $comment->getId();
});
```

### Resolving the authenticated user

[](#resolving-the-authenticated-user)

By default, when a new comment is made, the `Commenter` is automatically set to the current user logged in user (`auth()->user()`). If you want to change this behavior, you can implement your own resolver:

```
use Jodeveloper\\Commentions\Config;

Config::resolveAuthenticatedUserUsing(
    fn () => auth()->guard('my-guard')->user()
)
```

### Getting the mentioned Commenters from an existing comment

[](#getting-the-mentioned-commenters-from-an-existing-comment)

```
$comment->getMentioned()->each(function (Commenter $commenter) {
    // do something with $commenter...
});
```

### Polling for new comments

[](#polling-for-new-comments)

Commentions supports polling for new comments. You can enable it on any component by calling the `poll` method and passing the desired interval.

```
Infolists\Components\Section::make('Comments')
    ->schema([
        CommentsEntry::make('comments')
            ->poll('10s')
    ]),
```

### Rendering non-Comments in the list

[](#rendering-non-comments-in-the-list)

Sometimes you might want to render non-Comments in the list of comments. For example, you might want to render when the status of a project is changed. For this, you can override the `getComments` method in your model, and return instances of the `Jodeveloper\\Commentions\RenderableComment` data object.

```
use Jodeveloper\\Commentions\RenderableComment;

public function getComments(?int $limit = null): Collection
{
    $statusHistory = $this->statusHistory()->get()->map(fn (StatusHistory $statusHistory) => new RenderableComment(
        id: $statusHistory->id,
        authorName: $statusHistory->user->name,
        body: sprintf('Status changed from %s to %s', $statusHistory->old_status, $statusHistory->new_status),
        createdAt: $statusHistory->created_at,
    ));

    $comments = $this->comments()->latest()->with('author')->get();

    $mergedCollection = $statusHistory->merge($comments);

    if ($limit) {
        return $mergedCollection->take($limit);
    }

    return $mergedCollection;
}
```

---

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Luis Dalmolin](https://github.com/luisdalmolin)
- [All contributors](https://github.com/jodeveloper/commentions/graphs/contributors)

Sponsorship
-----------

[](#sponsorship)

Development of this package is sponsored by Kirschbaum Development Group, a developer driven company focused on problem solving, team building, and community. Learn more [about us](https://kirschbaumdevelopment.com?utm_source=github) or [join us](https://careers.kirschbaumdevelopment.com?utm_source=github)!

License
-------

[](#license)

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance64

Regular maintenance activity

Popularity6

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

3

Last Release

221d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/90a228b8f28fb5cf07826b801bb52e14e8b673b4f1f1f1ff65b4eca8519eba80?d=identicon)[JoDeveloper08](/maintainers/JoDeveloper08)

---

Top Contributors

[![luisdalmolin](https://avatars.githubusercontent.com/u/403446?v=4)](https://github.com/luisdalmolin "luisdalmolin (60 commits)")[![navneetrai](https://avatars.githubusercontent.com/u/195833?v=4)](https://github.com/navneetrai "navneetrai (29 commits)")[![adammparker](https://avatars.githubusercontent.com/u/5186174?v=4)](https://github.com/adammparker "adammparker (12 commits)")[![nathanheffley](https://avatars.githubusercontent.com/u/8952123?v=4)](https://github.com/nathanheffley "nathanheffley (7 commits)")[![JoDeveloper](https://avatars.githubusercontent.com/u/18007194?v=4)](https://github.com/JoDeveloper "JoDeveloper (4 commits)")[![agencetwogether](https://avatars.githubusercontent.com/u/53862310?v=4)](https://github.com/agencetwogether "agencetwogether (3 commits)")[![zvizvi](https://avatars.githubusercontent.com/u/4354421?v=4)](https://github.com/zvizvi "zvizvi (2 commits)")[![elmergustavo](https://avatars.githubusercontent.com/u/42653934?v=4)](https://github.com/elmergustavo "elmergustavo (2 commits)")[![klaare](https://avatars.githubusercontent.com/u/170330296?v=4)](https://github.com/klaare "klaare (1 commits)")[![KamranBiglari](https://avatars.githubusercontent.com/u/102748921?v=4)](https://github.com/KamranBiglari "KamranBiglari (1 commits)")[![silviugd](https://avatars.githubusercontent.com/u/26011825?v=4)](https://github.com/silviugd "silviugd (1 commits)")[![guetteman](https://avatars.githubusercontent.com/u/13571642?v=4)](https://github.com/guetteman "guetteman (1 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jodeveloper-commentions/health.svg)

```
[![Health](https://phpackages.com/badges/jodeveloper-commentions/health.svg)](https://phpackages.com/packages/jodeveloper-commentions)
```

###  Alternatives

[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)[konnco/filament-import

241243.2k2](/packages/konnco-filament-import)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58109.4k](/packages/laracraft-tech-laravel-useful-additions)[codebar-ag/laravel-filament-json-field

A Laravel Filament JSON Field integration with CodeMirror support

1124.1k](/packages/codebar-ag-laravel-filament-json-field)

PHPackages © 2026

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