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:
0
src/Concerns/.gitkeep
Normal file
0
src/Concerns/.gitkeep
Normal file
24
src/Concerns/HasComments.php
Normal file
24
src/Concerns/HasComments.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Relaticle\Comments\Concerns;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Relaticle\Comments\Config;
|
||||
|
||||
trait HasComments
|
||||
{
|
||||
public function comments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Config::getCommentModel(), 'commentable');
|
||||
}
|
||||
|
||||
public function topLevelComments(): MorphMany
|
||||
{
|
||||
return $this->comments()->whereNull('parent_id');
|
||||
}
|
||||
|
||||
public function commentCount(): int
|
||||
{
|
||||
return $this->comments()->count();
|
||||
}
|
||||
}
|
||||
27
src/Concerns/IsCommenter.php
Normal file
27
src/Concerns/IsCommenter.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Relaticle\Comments\Concerns;
|
||||
|
||||
use Filament\Models\Contracts\HasAvatar;
|
||||
use Filament\Models\Contracts\HasName;
|
||||
|
||||
trait IsCommenter
|
||||
{
|
||||
public function getCommentName(): string
|
||||
{
|
||||
if ($this instanceof HasName) {
|
||||
return $this->getFilamentName();
|
||||
}
|
||||
|
||||
return $this->name ?? 'Unknown';
|
||||
}
|
||||
|
||||
public function getCommentAvatarUrl(): ?string
|
||||
{
|
||||
if ($this instanceof HasAvatar) {
|
||||
return $this->getFilamentAvatarUrl();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user