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