feat: initial release of relaticle/comments

Filament comments package with:
- Polymorphic commenting on any Eloquent model
- Threaded replies with configurable depth
- @mentions with autocomplete and user search
- Emoji reactions with toggle and who-reacted tooltips
- File attachments via Livewire uploads
- Reply and mention notifications via Filament notification system
- Thread subscriptions for notification control
- Real-time broadcasting (opt-in Echo) with polling fallback
- Dark mode support
- CommentsAction, CommentsTableAction, CommentsEntry for Filament integration
- 204 tests, 421 assertions
This commit is contained in:
manukminasyan
2026-03-26 23:02:56 +04:00
commit 29fcbd8aec
88 changed files with 6581 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace Relaticle\Comments\Notifications;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Str;
use Relaticle\Comments\Comment;
use Relaticle\Comments\Config;
class UserMentionedNotification extends Notification
{
public function __construct(
public readonly Comment $comment,
public readonly Model $mentionedBy,
) {}
/** @return array<int, string> */
public function via(mixed $notifiable): array
{
return Config::getNotificationChannels();
}
/** @return array<string, mixed> */
public function toDatabase(mixed $notifiable): array
{
return [
'comment_id' => $this->comment->id,
'commentable_type' => $this->comment->commentable_type,
'commentable_id' => $this->comment->commentable_id,
'mentioner_name' => $this->mentionedBy->getCommentName(),
'body' => Str::limit(strip_tags($this->comment->body), 100),
];
}
public function toMail(mixed $notifiable): MailMessage
{
$mentionerName = $this->mentionedBy->getCommentName();
return (new MailMessage)
->subject('You were mentioned in a comment')
->line("{$mentionerName} mentioned you in a comment:")
->line(Str::limit(strip_tags($this->comment->body), 200));
}
}