phpinnacle / comments
Polymorphic record discussions for Laravel Livewire and Filament.
Requires
- php: ^8.4
- filament/filament: ^4.5|^5.0
- spatie/laravel-package-tools: ^1.92
Requires (Dev)
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-06 15:17:32 UTC
README
Comments provides polymorphic discussion threads for Eloquent records. It includes a Livewire thread, Filament action and infolist entry, comment policy, rich-text toolbar configuration and automatic pruning support. Mentions require Filament 4.5 or later.
Features
- Comments attached to any Eloquent model through a morph relation.
- Livewire list and creation form.
- Comment editing and one-level contextual replies.
- Thread subscriptions and direct mentions.
- Filament
CommentsActionmodal andCommentsEntryinfolist component. - Author association using a configurable user model.
- Policy-backed access and configurable editor toolbar.
- Configurable database connection and retention period.
Installation
composer require phpinnacle/comments
php artisan vendor:publish --tag="phpinnacle-comments-migrations"
php artisan migrate
Publish configuration or views only when customization is required:
php artisan vendor:publish --tag="phpinnacle-comments-config" php artisan vendor:publish --tag="phpinnacle-comments-views"
Set user.model to the authenticatable model used by the application. prune controls retention in days, while toolbar controls the enabled formatting buttons.
Subscriptions and mentions use Laravel database notifications. The configured user model must use Laravel's Notifiable trait and expose a name attribute. Run php artisan make:notifications-table before migrating when the application does not already have a notifications table.
Filament usage
use PHPinnacle\Comments\Actions\CommentsAction; use PHPinnacle\Comments\Infolists\CommentsEntry; CommentsAction::make(); CommentsEntry::make('comments');
Authorization is delegated to CommentPolicy. Its create, update, and delete abilities control the corresponding thread actions; use update to limit editing to comment authors. Replies quote one root comment rather than forming an arbitrarily deep tree. If pruning is desired, schedule Laravel's model:prune command.
The infolist entry is hidden for guests and checks the viewAny ability for authenticated users.
Testing
composer test
Changelog and license
See CHANGELOG. Released under the MIT License.