Add ability to delete comments by moderators
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user