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\Policies;
use App\Enums\UserRole;
use App\Models\Comment;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
@@ -17,6 +18,11 @@ class CommentPolicy
public function destroy(User $user, Comment $comment): bool
{
if ($user->hasRole(UserRole::ADMINISTRATOR) ||
$user->hasRole(UserRole::MODERATOR)) {
return true;
}
return $user->id === $comment->user_id;
}
}