Deploy 1.x docs

This commit is contained in:
github-actions[bot]
2026-03-27 11:03:10 +00:00
parent 3ab8c24b67
commit 7c9f000e60
109 changed files with 273 additions and 239 deletions

View File

@@ -141,7 +141,7 @@ When a comment is deleted, its attachments are cascade deleted from the database
## Helper Methods
The `CommentAttachment` model provides:
The `Attachment` model (`Relaticle\Comments\Models\Attachment`) provides:
```php
$attachment->isImage(); // Check if attachment is an image

View File

@@ -121,34 +121,34 @@ Create your own policy to customize authorization:
```php
namespace App\Policies;
use Relaticle\Comments\Comment;
use Relaticle\Comments\Contracts\Commenter;
use Relaticle\Comments\Models\Comment;
use Relaticle\Comments\Contracts\Commentator;
class CustomCommentPolicy
{
public function viewAny(Commenter $user): bool
public function viewAny(Commentator $user): bool
{
return true;
}
public function create(Commenter $user): bool
public function create(Commentator $user): bool
{
return true;
}
public function update(Commenter $user, Comment $comment): bool
public function update(Commentator $user, Comment $comment): bool
{
return $comment->user_id === $user->getKey()
&& $comment->user_type === $user->getMorphClass();
return $comment->commenter_id === $user->getKey()
&& $comment->commenter_type === $user->getMorphClass();
}
public function delete(Commenter $user, Comment $comment): bool
public function delete(Commentator $user, Comment $comment): bool
{
return $comment->user_id === $user->getKey()
return $comment->commenter_id === $user->getKey()
|| $user->hasRole('admin');
}
public function reply(Commenter $user, Comment $comment): bool
public function reply(Commentator $user, Comment $comment): bool
{
return $comment->canReply();
}

View File

@@ -10,21 +10,34 @@ php artisan vendor:publish --tag=comments-config
This creates `config/comments.php` with all available options.
## Table Name
## Table Names
```php
'tables' => [
'table_names' => [
'comments' => 'comments',
'reactions' => 'comment_reactions',
'mentions' => 'comment_mentions',
'subscriptions' => 'comment_subscriptions',
'attachments' => 'comment_attachments',
],
```
Change the table name if it conflicts with your application.
Change the table names if they conflict with your application.
## Column Names
```php
'column_names' => [
'commenter_id' => 'commenter_id',
'commenter_type' => 'commenter_type',
],
```
## Models
```php
'models' => [
'comment' => \Relaticle\Comments\Comment::class,
'comment' => \Relaticle\Comments\Models\Comment::class,
],
'commenter' => [
@@ -173,10 +186,10 @@ When broadcasting is disabled, the Livewire component polls for new comments at
Override how the authenticated user is resolved:
```php
use Relaticle\Comments\Config;
use Relaticle\Comments\CommentsConfig;
// In AppServiceProvider::boot()
Config::resolveAuthenticatedUserUsing(function () {
CommentsConfig::resolveAuthenticatedUserUsing(function () {
return auth()->user();
});
```

View File

@@ -79,7 +79,7 @@ The main comments table with polymorphic relationships and threading support.
<tr>
<td>
<code>
user_type
commenter_type
</code>
</td>
@@ -95,7 +95,7 @@ The main comments table with polymorphic relationships and threading support.
<tr>
<td>
<code>
user_id
commenter_id
</code>
</td>
@@ -265,7 +265,7 @@ Tracks emoji reactions per user per comment.
<tr>
<td>
<code>
user_type
commenter_type
</code>
</td>
@@ -281,7 +281,7 @@ Tracks emoji reactions per user per comment.
<tr>
<td>
<code>
user_id
commenter_id
</code>
</td>
@@ -332,7 +332,7 @@ Tracks emoji reactions per user per comment.
</tbody>
</table>
**Unique constraint:** `(comment_id, user_id, user_type, reaction)`
**Unique constraint:** `(comment_id, commenter_id, commenter_type, reaction)`
### comment_mentions
@@ -391,7 +391,7 @@ Tracks @mentioned users per comment.
<tr>
<td>
<code>
user_type
commenter_type
</code>
</td>
@@ -407,7 +407,7 @@ Tracks @mentioned users per comment.
<tr>
<td>
<code>
user_id
commenter_id
</code>
</td>
@@ -438,7 +438,7 @@ Tracks @mentioned users per comment.
</tbody>
</table>
**Unique constraint:** `(comment_id, user_id, user_type)`
**Unique constraint:** `(comment_id, commenter_id, commenter_type)`
### comment_subscriptions
@@ -513,7 +513,7 @@ Tracks which users are subscribed to comment threads on specific models.
<tr>
<td>
<code>
user_type
commenter_type
</code>
</td>
@@ -529,7 +529,7 @@ Tracks which users are subscribed to comment threads on specific models.
<tr>
<td>
<code>
user_id
commenter_id
</code>
</td>
@@ -560,7 +560,7 @@ Tracks which users are subscribed to comment threads on specific models.
</tbody>
</table>
**Unique constraint:** `(commentable_type, commentable_id, user_type, user_id)`
**Unique constraint:** `(commentable_type, commentable_id, commenter_type, commenter_id)`
### comment_attachments
@@ -735,11 +735,11 @@ Stores file attachment metadata for comments.
```text
Commentable Model (e.g., Project)
└── comments (morphMany)
├── user (morphTo → User)
├── commenter (morphTo → User)
├── parent (belongsTo → Comment)
├── replies (hasMany → Comment)
├── reactions (hasMany → CommentReaction)
├── attachments (hasMany → CommentAttachment)
├── reactions (hasMany → Reaction)
├── attachments (hasMany → Attachment)
└── mentions (morphToMany → User)
```

View File

@@ -57,17 +57,17 @@ Users can toggle their subscription using the subscribe/unsubscribe button in th
### Programmatic Access
```php
use Relaticle\Comments\CommentSubscription;
use Relaticle\Comments\Models\Subscription;
// Check subscription status
CommentSubscription::isSubscribed($commentable, $user);
Subscription::isSubscribed($commentable, $user);
// Subscribe/unsubscribe
CommentSubscription::subscribe($commentable, $user);
CommentSubscription::unsubscribe($commentable, $user);
Subscription::subscribe($commentable, $user);
Subscription::unsubscribe($commentable, $user);
// Get all subscribers for a commentable
$subscribers = CommentSubscription::subscribersFor($commentable);
$subscribers = Subscription::subscribersFor($commentable);
```
## Events

View File

@@ -150,4 +150,4 @@ Keys are stored in the database. If you change a key, existing reactions with th
## Storage
Reactions are stored in the `comment_reactions` table with a unique constraint on `(comment_id, user_id, user_type, reaction)`, ensuring one reaction of each type per user per comment.
Reactions are stored in the `comment_reactions` table with a unique constraint on `(comment_id, commenter_id, commenter_type, reaction)`, ensuring one reaction of each type per user per comment.