You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Added renderable interface
* Added L12
* Removed -dev
* Added a proper way to rewrite the get comments function
* Added pooling
* Readme
* Readme
* Readme
* Fixed test
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.
10
10
11
+

12
+
11
13
## Installation
12
14
13
15
```bash
@@ -47,7 +49,9 @@ class Project extends Model implements Commentable
47
49
48
50
### Usage with Filament
49
51
50
-
1. And register the component in your Filament Infolists:
52
+
There are a couple of ways to use Commentions with Filament.
53
+
54
+
1. Register the component in your Filament Infolists:
51
55
52
56
```php
53
57
Infolists\Components\Section::make('Comments')
@@ -82,13 +86,11 @@ protected function getHeaderActions(): array
82
86
}
83
87
```
84
88
85
-
And that's it!
86
-
87
-

89
+
***
88
90
89
91
### Configuring the User model and the mentionables
90
92
91
-
If your `User` model lives in a different namespace than `App\Models\User`, you can configure it in the `config/commentions.php` file:
93
+
If your `User` model lives in a different namespace than `App\Models\User`, you can configure it in `config/commentions.php`:
Commentions supports polling for new comments. You can enable it by setting the `pollingEnabled` property to `true` and setting the `pollingInterval` property to the number of seconds between polls when you register the component.
180
+
181
+
```php
182
+
Infolists\Components\Section::make('Comments')
183
+
->schema([
184
+
Livewire::make(Comments::class, [
185
+
'pollingEnabled' => true,
186
+
'pollingInterval' => 30, // optional, default is 60 seconds
187
+
])
188
+
]),
189
+
```
190
+
191
+
### Rendering non-Comments in the list
192
+
193
+
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.
194
+
195
+
```php
196
+
use Kirschbaum\Commentions\RenderableComment;
197
+
198
+
public function getComments(): Collection
199
+
{
200
+
$statusHistory = $this->statusHistory()->get()->map(fn (StatusHistory $statusHistory) => new RenderableComment(
201
+
authorName: $statusHistory->user->name,
202
+
body: sprintf('Status changed from %s to %s', $statusHistory->old_status, $statusHistory->new_status),
0 commit comments