From a4d4418963070f67add6f4a48a2aa74ea5448173 Mon Sep 17 00:00:00 2001 From: manukminasyan Date: Fri, 27 Mar 2026 15:01:50 +0400 Subject: [PATCH] docs: update all documentation for refactored naming conventions - CanComment trait replaces IsCommenter - Commentator interface replaces Commenter - Models moved to Models\ namespace (Comment, Reaction, Attachment, Subscription) - commenter_type/commenter_id columns replace user_type/user_id - CommentsConfig replaces Config class - table_names config key replaces tables - getCommentDisplayName() replaces getCommentName() --- README.md | 8 ++--- docs/.data/content/contents.sqlite | Bin 307200 -> 323584 bytes .../1.getting-started/2.installation.md | 10 +++---- docs/content/2.essentials/1.configuration.md | 25 ++++++++++++---- docs/content/2.essentials/2.authorization.md | 20 ++++++------- docs/content/2.essentials/4.reactions.md | 2 +- docs/content/2.essentials/5.attachments.md | 2 +- docs/content/2.essentials/6.notifications.md | 10 +++---- .../content/2.essentials/7.database-schema.md | 28 +++++++++--------- .../skills/comments-development/SKILL.md | 24 +++++++-------- 10 files changed, 71 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index ee5d476..041448a 100644 --- a/README.md +++ b/README.md @@ -61,12 +61,12 @@ class Project extends Model implements Commentable Add the commenter trait to your User model: ```php -use Relaticle\Comments\Concerns\IsCommenter; -use Relaticle\Comments\Contracts\Commenter; +use Relaticle\Comments\Concerns\CanComment; +use Relaticle\Comments\Contracts\Commentator; -class User extends Authenticatable implements Commenter +class User extends Authenticatable implements Commentator { - use IsCommenter; + use CanComment; } ``` diff --git a/docs/.data/content/contents.sqlite b/docs/.data/content/contents.sqlite index 178b545d49bd60044c12eb72b503744ce2c45202..bb932e22f455e58492a5700242ff7ebed3bf58e6 100644 GIT binary patch delta 8100 zcmeHM32+-#n%3*rz9Y47I|sHRCvhNBtoumtDc`ni%kr56yRB~7vUS;#9Xo-E1zQUf zW>_l?yn%tl5Q+?EtY~nvuzHML}4OSu=8@)WgO zGc~GuPu=hR|LfQP`>*fs$y4c*r!uBiip?UCs2R80aRZ_C24D{NK1HoaqCUg}A}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6*1L`FUZX*;bLo2RI@e7<|B;5;{e}jA zo7`3u7WG*7KbrnK7W4n|BIAv#MUA!v-af*}ZX1n{9%1UxJyxS%vJDAvF*klZ{0kBO zMKqF$jo;dto>*8vj~rgR&*|~?DLg)>Yoch-snn}QXpK24cz;OvY>lA z7c5njLWw4s5=9av7BM9SWIl{bWn4?qgS2=F_&WI}*iNF*IuG7Gj31ihV>9@~gZ z7wj}l7)JfWL*sRAEly*=SXJ3<(>5DNihZs1y>6S*9PIbi+EN9CT5atQxs`nrE#m=e z$UN5HRa;(O^!7XMDG%d2~SCGo-eTIS923MbAL#ijo0y~&p^;PzEEqS7q$1oLjhM0I*rp`5KKp|Q`9>G>e6mp3bT6KYV)6rW zmQ}34tEixoLnj(wLlIgNM|%+Z7{75hbaTp(3ZlQms?Q%-#!g->LExW5;^erIB=aK4 zd^B=IlJw8plGB>=roXX`f5Jev$BULP-lvsn9oRQFa^@&Clm-JwGlDu(G_p<@DW zu*Bh@2xi_SyZ%J^{rjY?D+spvU4$rkvV`AY6)T81da#FL_SX{7=hni6$(_!{EV$V= zICYKD3jNiqEE4f06pN4hxJ@6SJOL@M{xg7N_)ZV% zqUfF3mOwYyVdqY^uYnV%DVDegqaR6yru}GLf{HSgaDl<~@Np@shVXw<#{UiYcgh5q zpC#C$l#9IACv*%UR_GDpV3D{ PX*BW*;m_ufZK?ka{^J6u diff --git a/docs/content/1.getting-started/2.installation.md b/docs/content/1.getting-started/2.installation.md index d30479c..4c36414 100644 --- a/docs/content/1.getting-started/2.installation.md +++ b/docs/content/1.getting-started/2.installation.md @@ -73,15 +73,15 @@ class Project extends Model implements Commentable } ``` -Add the `IsCommenter` trait to your User model: +Add the `CanComment` trait to your User model: ```php [app/Models/User.php] -use Relaticle\Comments\Concerns\IsCommenter; -use Relaticle\Comments\Contracts\Commenter; +use Relaticle\Comments\Concerns\CanComment; +use Relaticle\Comments\Contracts\Commentator; -class User extends Authenticatable implements Commenter +class User extends Authenticatable implements Commentator { - use IsCommenter; + use CanComment; } ``` diff --git a/docs/content/2.essentials/1.configuration.md b/docs/content/2.essentials/1.configuration.md index 1e8dc8e..819b1de 100644 --- a/docs/content/2.essentials/1.configuration.md +++ b/docs/content/2.essentials/1.configuration.md @@ -15,21 +15,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' => [ @@ -178,10 +191,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(); }); ``` diff --git a/docs/content/2.essentials/2.authorization.md b/docs/content/2.essentials/2.authorization.md index 551f289..395f25e 100644 --- a/docs/content/2.essentials/2.authorization.md +++ b/docs/content/2.essentials/2.authorization.md @@ -26,34 +26,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(); } diff --git a/docs/content/2.essentials/4.reactions.md b/docs/content/2.essentials/4.reactions.md index c972179..e18bd12 100644 --- a/docs/content/2.essentials/4.reactions.md +++ b/docs/content/2.essentials/4.reactions.md @@ -48,4 +48,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. diff --git a/docs/content/2.essentials/5.attachments.md b/docs/content/2.essentials/5.attachments.md index 04005d7..1d84a01 100644 --- a/docs/content/2.essentials/5.attachments.md +++ b/docs/content/2.essentials/5.attachments.md @@ -63,7 +63,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 diff --git a/docs/content/2.essentials/6.notifications.md b/docs/content/2.essentials/6.notifications.md index 4f0700f..b583a92 100644 --- a/docs/content/2.essentials/6.notifications.md +++ b/docs/content/2.essentials/6.notifications.md @@ -61,17 +61,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 diff --git a/docs/content/2.essentials/7.database-schema.md b/docs/content/2.essentials/7.database-schema.md index ece9978..7c868ef 100644 --- a/docs/content/2.essentials/7.database-schema.md +++ b/docs/content/2.essentials/7.database-schema.md @@ -20,8 +20,8 @@ The main comments table with polymorphic relationships and threading support. | `id` | bigint | Primary key | | `commentable_type` | string | Polymorphic model type | | `commentable_id` | bigint | Polymorphic model ID | -| `user_type` | string | Commenter model type | -| `user_id` | bigint | Commenter model ID | +| `commenter_type` | string | Commenter model type | +| `commenter_id` | bigint | Commenter model ID | | `parent_id` | bigint (nullable) | Parent comment for replies | | `body` | text | HTML comment content | | `edited_at` | timestamp (nullable) | When the comment was last edited | @@ -39,12 +39,12 @@ Tracks emoji reactions per user per comment. |--------|------|-------------| | `id` | bigint | Primary key | | `comment_id` | bigint | Foreign key to comments | -| `user_type` | string | Reactor model type | -| `user_id` | bigint | Reactor model ID | +| `commenter_type` | string | Reactor model type | +| `commenter_id` | bigint | Reactor model ID | | `reaction` | string | Reaction key (e.g., `thumbs_up`) | | `created_at` | timestamp | | -**Unique constraint:** `(comment_id, user_id, user_type, reaction)` +**Unique constraint:** `(comment_id, commenter_id, commenter_type, reaction)` ### comment_mentions @@ -54,11 +54,11 @@ Tracks @mentioned users per comment. |--------|------|-------------| | `id` | bigint | Primary key | | `comment_id` | bigint | Foreign key to comments | -| `user_type` | string | Mentioned user model type | -| `user_id` | bigint | Mentioned user model ID | +| `commenter_type` | string | Mentioned user model type | +| `commenter_id` | bigint | Mentioned user model ID | | `created_at` | timestamp | | -**Unique constraint:** `(comment_id, user_id, user_type)` +**Unique constraint:** `(comment_id, commenter_id, commenter_type)` ### comment_subscriptions @@ -69,11 +69,11 @@ Tracks which users are subscribed to comment threads on specific models. | `id` | bigint | Primary key | | `commentable_type` | string | Subscribed model type | | `commentable_id` | bigint | Subscribed model ID | -| `user_type` | string | Subscriber model type | -| `user_id` | bigint | Subscriber model ID | +| `commenter_type` | string | Subscriber model type | +| `commenter_id` | bigint | Subscriber model ID | | `created_at` | timestamp | | -**Unique constraint:** `(commentable_type, commentable_id, user_type, user_id)` +**Unique constraint:** `(commentable_type, commentable_id, commenter_type, commenter_id)` ### comment_attachments @@ -96,11 +96,11 @@ Stores file attachment metadata for comments. ``` 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) ``` diff --git a/resources/boost/skills/comments-development/SKILL.md b/resources/boost/skills/comments-development/SKILL.md index 89e49c9..bbb5e34 100644 --- a/resources/boost/skills/comments-development/SKILL.md +++ b/resources/boost/skills/comments-development/SKILL.md @@ -31,12 +31,12 @@ class Project extends Model implements Commentable ``` ```php -use Relaticle\Comments\Concerns\IsCommenter; -use Relaticle\Comments\Contracts\Commenter; +use Relaticle\Comments\Concerns\CanComment; +use Relaticle\Comments\Contracts\Commentator; -class User extends Authenticatable implements Commenter +class User extends Authenticatable implements Commentator { - use IsCommenter; + use CanComment; } ``` @@ -113,7 +113,7 @@ Publish config: `php artisan vendor:publish --tag=comments-config` | Key | Default | Purpose | |-----|---------|---------| -| `tables.comments` | `'comments'` | Main comments table name | +| `table_names.comments` | `'comments'` | Main comments table name | | `models.comment` | `Comment::class` | Comment model class | | `commenter.model` | `User::class` | Commenter (user) model class | | `policy` | `CommentPolicy::class` | Authorization policy class | @@ -183,14 +183,14 @@ Default `CommentPolicy` methods: ```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 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'); } } @@ -201,10 +201,10 @@ class CustomCommentPolicy ### Scoped Comments (Multi-tenancy) ```php -use Relaticle\Comments\Config; +use Relaticle\Comments\CommentsConfig; // In AppServiceProvider::boot() -Config::resolveAuthenticatedUserUsing(function () { +CommentsConfig::resolveAuthenticatedUserUsing(function () { return auth()->user(); }); ``` @@ -276,7 +276,7 @@ $model->commentCount(); // Total count // On Comment model $comment->commentable(); // Parent model (morphTo) -$comment->user(); // Commenter (morphTo) +$comment->commenter(); // Commenter (morphTo) $comment->parent(); // Parent comment (belongsTo) $comment->replies(); // Child comments (hasMany) $comment->reactions(); // Reactions (hasMany)