Download the PHP package ssntpl/laravel-comments without Composer
On this page you can find all versions of the php package ssntpl/laravel-comments. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ssntpl/laravel-comments
More information about ssntpl/laravel-comments
Files in ssntpl/laravel-comments
Package laravel-comments
Short Description Polymorphic comments for Eloquent models: threading, reactions, per-comment files, opt-in edit history, mentions, and lifecycle events.
License MIT
Informations about the package laravel-comments
laravel-comments
This is a simple package to associate comments with your eloquent model in laravel. This package is providing functionality for adding, retrieving, editing, and deleting comments along with its associated files if any on various entities:
Installation
You can install the package via composer:
Run the migrations with:
Optionally, You can publish and run the migrations with:
Publish the config to customise behaviour (user model, edit history, mention pattern, etc.):
Apps that already own a
commentstable (and manage the schema themselves) can setcomments.auto_load_migrationstofalseso the package does not register its own migrations.
Usage
Add the HasComments trait to your model.
Add new comment to the model.
Accessing the comment model.
Threading (replies)
A comment can reply to another via reply_to_comment_id:
Reactions
One reaction per user per comment (re-reacting changes it):
Edit history (opt-in)
Set comments.changelog to true to snapshot each edit. On every change to body,
the previous body is stored in comment_changelogs, so the changelog table holds all
prior versions and the model holds the current one — the full history is reconstructable.
Mentions
The package parses @handles out of the body; resolving them to users and delivering
notifications is your app's job (typically in a listener on the events below).
The pattern is configurable via comments.mentions.pattern.
Events
The package fires framework-agnostic events so your app can send notifications, broadcast, or record activity without the package knowing about any of that:
| Event | When |
|---|---|
CommentCreated |
a comment is created |
CommentUpdated |
a comment's body is edited (carries previousBody) |
CommentDeleted |
a comment is deleted |
ReactionAdded |
a user reacts (or changes their reaction) |
ReactionRemoved |
a user removes their reaction |
Overriding models
Point comments.models.* at your own subclasses to add behaviour. Custom classes must
extend the package base (Comment / CommentReaction / CommentChangelog).
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Jyotsana Sharma
- All Contributors
License
The MIT License (MIT). Please see License File for more information.