docs: add README, boost skill, and documentation site

This commit is contained in:
manukminasyan
2026-03-27 00:29:57 +04:00
parent 29fcbd8aec
commit b8d930df1a
25 changed files with 1741 additions and 3 deletions

View File

@@ -0,0 +1,125 @@
---
title: Notifications
description: Comment notifications, subscriptions, and real-time updates.
navigation:
icon: i-lucide-bell
seo:
description: Configure comment notifications, subscriptions, broadcasting, and polling.
---
## Notification Types
Two notification classes are included:
### CommentRepliedNotification
Sent to all thread subscribers when a new comment or reply is posted. The comment author is excluded from receiving their own notification.
### UserMentionedNotification
Sent to a user when they are @mentioned in a comment. Self-mentions are ignored.
## Channels
```php
// config/comments.php
'notifications' => [
'channels' => ['database'],
'enabled' => true,
],
```
Available channels: `'database'` and `'mail'`. Add both to send email notifications alongside database notifications:
```php
'notifications' => [
'channels' => ['database', 'mail'],
'enabled' => true,
],
```
## Subscriptions
Users can subscribe to comment threads on any commentable model. Subscribers receive notifications when new comments are posted.
### Auto-Subscribe
```php
'subscriptions' => [
'auto_subscribe' => true,
],
```
When enabled:
- Users are auto-subscribed when they post a comment
- Users are auto-subscribed when they are @mentioned
### Manual Subscription
Users can toggle their subscription using the subscribe/unsubscribe button in the comments UI.
### Programmatic Access
```php
use Relaticle\Comments\CommentSubscription;
// Check subscription status
CommentSubscription::isSubscribed($commentable, $user);
// Subscribe/unsubscribe
CommentSubscription::subscribe($commentable, $user);
CommentSubscription::unsubscribe($commentable, $user);
// Get all subscribers for a commentable
$subscribers = CommentSubscription::subscribersFor($commentable);
```
## Events
| Event | Trigger | Broadcasts |
|-------|---------|------------|
| `CommentCreated` | New comment or reply | Yes |
| `CommentUpdated` | Comment edited | Yes |
| `CommentDeleted` | Comment soft-deleted | Yes |
| `CommentReacted` | Reaction added/removed | Yes |
| `UserMentioned` | User @mentioned | No |
## Real-time Updates
### Broadcasting
Enable broadcasting for instant updates across browser sessions:
```php
// config/comments.php
'broadcasting' => [
'enabled' => true,
'channel_prefix' => 'comments',
],
```
Events are broadcast on private channels: `{prefix}.{commentable_type}.{commentable_id}`
This requires Laravel Echo and a broadcasting driver (Pusher, Ably, etc.) configured in your application.
### Polling Fallback
When broadcasting is disabled, the Livewire component polls for updates:
```php
'polling' => [
'interval' => '10s',
],
```
Set to `null` to disable polling entirely.
## Disabling Notifications
```php
'notifications' => [
'enabled' => false,
],
```
This disables all notification dispatching. Subscriptions and events still work, but no notifications are sent.