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
Copy file name to clipboardExpand all lines: README.md
+122-2Lines changed: 122 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,7 +103,7 @@ use Kirschbaum\Commentions\Filament\Actions\CommentsAction;
103
103
CommentsAction::make()
104
104
->mentionables(User::all())
105
105
])
106
-
````
106
+
```
107
107
108
108
3. Or as a header action:
109
109
@@ -120,6 +120,100 @@ protected function getHeaderActions(): array
120
120
}
121
121
```
122
122
123
+
### Subscription Management
124
+
125
+
Commentions includes a subscription system that allows users to subscribe to receive notifications when new comments are added to a commentable resource.
126
+
127
+
#### Subscription Actions
128
+
129
+
You can add subscription actions to your Filament resources:
130
+
131
+
```php
132
+
use Kirschbaum\Commentions\Filament\Actions\SubscriptionAction;
133
+
134
+
// In header actions
135
+
protected function getHeaderActions(): array
136
+
{
137
+
return [
138
+
SubscriptionAction::make(),
139
+
];
140
+
}
141
+
142
+
// In table actions (Filament 3)
143
+
->actions([
144
+
SubscriptionTableAction::make(),
145
+
])
146
+
147
+
// In record actions (Filament 4)
148
+
->recordActions([
149
+
SubscriptionAction::make(),
150
+
])
151
+
```
152
+
153
+
#### Subscription Sidebar
154
+
155
+
When using comments in modals, a subscription sidebar is automatically displayed showing:
156
+
- Subscribe/unsubscribe button for the current user
157
+
- List of users currently subscribed to the commentable
158
+
- Real-time updates when subscription status changes
159
+
160
+
##### Livewire options
161
+
162
+
When using the `commentions::comments` Livewire component directly, you can control the sidebar and its contents via component properties:
163
+
164
+
-`sidebarEnabled` (bool, default: true): toggles the entire subscription sidebar
165
+
-`showSubscribers` (bool, default: `config('commentions.subscriptions.show_subscribers', true)`): toggles the subscribers list within the sidebar
When a new comment is created, all subscribed users receive notifications through the `UserIsSubscribedToCommentableEvent`. You can listen to this event to send custom notifications:
429
+
430
+
```php
431
+
namespace App\Listeners;
432
+
433
+
use Illuminate\Queue\InteractsWithQueue;
434
+
use Illuminate\Contracts\Queue\ShouldQueue;
435
+
use App\Notifications\NewCommentNotification;
436
+
use Kirschbaum\Commentions\Events\UserIsSubscribedToCommentableEvent;
437
+
438
+
class SendSubscribedUserNotification implements ShouldQueue
439
+
{
440
+
use InteractsWithQueue;
441
+
442
+
public functionhandle(UserIsSubscribedToCommentableEvent$event): void
443
+
{
444
+
$event->user->notify(
445
+
new NewCommentNotification($event->comment)
446
+
);
447
+
}
448
+
}
449
+
```
450
+
331
451
### Sending notifications when a user is mentioned
332
452
333
453
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.
0 commit comments