opscale-co/nova-comments

Polymorphic comments field for any Laravel Nova Resource — Opscale fork of kirschbaum-development/nova-comments.

Maintainers

Package info

github.com/opscale-co/nova-comments

Language:Shell

pkg:composer/opscale-co/nova-comments

Statistics

Installs: 2

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2026-06-14 21:48 UTC

This package is auto-updated.

Last update: 2026-06-14 21:49:31 UTC


README

At Opscale, we’re passionate about contributing to the open-source community by providing solutions that help businesses scale efficiently. If you’ve found our tools helpful, here are a few ways you can show your support:

Star this repository to help others discover our work and be part of our growing community. Every star makes a difference!

💬 Share your experience by leaving a review on Trustpilot or sharing your thoughts on social media.

📧 Send us feedback on what we can improve at feedback@opscale.co.

🙏 Get involved by actively contributing to our open-source repositories.

💼 Hire us at hire@opscale.co for custom dashboards, admin panels, internal tools, or MVPs.

Thanks for helping Opscale continue to scale! 🚀

opscale-co/nova-comments

A Laravel Nova 5 field that adds polymorphic comments to any Nova Resource. This is the Opscale-maintained fork of kirschbaum-development/nova-comments — same surface area (Commenter ResourceTool, Commentable trait, CommentsPanel, nova_comments table, whenCreating sanitization hook) under Opscale conventions (declare(strict_types=1), PHPStan level 8, Duster, Semantic Release, single-tenant deployment model).

Installation

Latest Version on Packagist

composer require opscale-co/nova-comments
php artisan migrate

The service provider auto-registers via package discovery. Publish the config if you need to customize it:

php artisan vendor:publish --tag=nova-comments-config

Usage

1. Add the Commentable trait to a model

use Opscale\NovaComments\Commentable;

class Post extends Model
{
    use Commentable;
}

2. Add the Commenter field to the model's Nova Resource

use Opscale\NovaComments\Commenter;

public function fields(NovaRequest $request): array
{
    return [
        // ... your other fields ...
        Commenter::make(),
    ];
}

That's it. The comments panel renders on the resource detail page with a Trix rich-text editor (bold, italic, lists, links, etc.). Authenticated Nova users can write comments, paginate older / newer, and submit with the Save button or ⌘+Enter.

Alternative: the relationship panel

Prefer Nova's standard relationship table over the inline panel? Use the CommentsPanel:

use Opscale\NovaComments\CommentsPanel;

public function fields(NovaRequest $request): array
{
    return [
        // ... fields ...
        new CommentsPanel(),
    ];
}

Custom sanitization

By default, comments are stored as the Trix-produced HTML as-is. Trix sanitizes input client-side (no <script>, no inline event handlers), which covers the common case. If you need server-side sanitization — Markdown rendering, an HTML purifier, or just to be paranoid about direct API calls — register a callback in a service provider:

use Opscale\NovaComments\Models\Comment;

public function boot(): void
{
    Comment::whenCreating(function (Comment $comment): void {
        $comment->comment = MyPurifier::clean($comment->comment);
    });
}

Pass null to clear the callback.

Configuration

config/nova-comments.php:

Key Default Purpose
commenter.nova-resource \App\Nova\User::class Nova resource used for the commenter BelongsTo field
comments-panel.name null (uses translation) Heading shown above the panel
limit 100 Max length of the comment preview on the index page

Testing

composer install
vendor/bin/phpunit --exclude-testsuite=Browser

Browser (Dusk) tests run against a workbench Nova app:

npm ci && npm run prod      # build dist/ assets
vendor/bin/phpunit --testsuite=Browser

Changelog

See CHANGELOG.

Contributing

Please see CONTRIBUTING.

Credits

License

The MIT License (MIT). Please see License File.