Add ability to delete comments by moderators

This commit is contained in:
2026-05-06 19:02:50 +02:00
parent 59cb39ca77
commit fdf26604f3
9 changed files with 127 additions and 33 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Livewire;
use App\Enums\UserRole;
use App\Models\Episode;
use App\Models\User;
use App\Notifications\CommentNotification;
@@ -43,7 +44,7 @@ class Comment extends Component
'replyState.body' => 'reply',
];
public function updatedIsEditing($isEditing)
public function updatedIsEditing(bool $isEditing)
{
if (! $isEditing) {
return;
@@ -67,6 +68,15 @@ class Comment extends Component
{
$this->authorize('destroy', $this->comment);
$user = Auth::user();
if ($user->hasRole(UserRole::ADMINISTRATOR) || $user->hasRole(UserRole::MODERATOR)) {
$this->comment->deleted_by_moderator_id = $user->id;
$this->comment->save();
$this->dispatch('refresh');
return;
}
$this->comment->delete();
$this->dispatch('refresh');