Download the PHP package kirschbaum-development/commentions without Composer
On this page you can find all versions of the php package kirschbaum-development/commentions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kirschbaum-development/commentions
More information about kirschbaum-development/commentions
Files in kirschbaum-development/commentions
Package commentions
Short Description A package to allow you to create comments, tag users and more
License MIT
Informations about the package commentions
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.
Installation
Usage
-
Publish the migrations
-
In your
User
model implement theCommenter
interface. - In the model you want to add comments, implement the
Commentable
interface and theHasComments
trait.
Usage with Filament
There are a couple of ways to use Commentions with Filament.
- Register the component in your Filament Infolists:
This works for Filament 3 and 4.
- Or in your table actions:
If you are using Filament 3, you must use CommentsTableAction
in your table's actions
array:
If you are using Filament 4, you should use CommentsAction
in recordActions
instead:
`
- Or as a header action:
This works for Filament 3 and 4.
Configuration
You can publish the configuration file to make changes.
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
:
Configuring the Comment model
If you need to customize the Comment model, you can extend the \Kirschbaum\Commentions\Comment
class and then update the comment.model
option in your config/commentions.php
file:
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
2) Register your policy in the configuration file
Update the comment.policy
option in your config/commentions.php
file:
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.
Configuring the Commenter avatar
To configure the avatar, make sure your User model implements Filament's HasAvatar
interface.
Events
Two events are dispatched when a comment is created or reacted to:
Kirschbaum\Commentions\Events\UserWasMentionedEvent
Kirschbaum\Commentions\Events\CommentWasReactedEvent
Sending notifications when a user is mentioned
Every time a user is mentioned, the Kirschbaum\Commentions\Events\UserWasMentionedEvent
is dispatched. You can listen to this event and send notifications to the mentioned user.
Example usage:
If you have event auto-discovery, this should be enough. Otherwise, make sure to register your listener on the EventServiceProvider
.
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:
Getting the mentioned Commenters from an existing comment
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.
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 Kirschbaum\Commentions\RenderableComment
data object.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
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 or join us!
License
The MIT License (MIT). Please see License File for more information.
All versions of commentions with dependencies
league/html-to-markdown Version ^5.1
illuminate/support Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
livewire/livewire Version ^3.5
filament/support Version ^3.2|^4.0
filament/notifications Version ^3.2|^4.0
filament/filament Version ^3.2|^4.0