X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/2fd421b115132cdea97ec5ccbbab412e02659ab7..refs/pull/261/head:/app/Repos/CommentRepo.php diff --git a/app/Repos/CommentRepo.php b/app/Repos/CommentRepo.php index 83847239f..ce71b9234 100644 --- a/app/Repos/CommentRepo.php +++ b/app/Repos/CommentRepo.php @@ -31,10 +31,26 @@ class CommentRepo { return $comment; } - public function update($comment, $input) { + public function update($comment, $input, $activeOnly = true) { $userId = user()->id; $comment->updated_by = $userId; $comment->fill($input); + + // only update active comments by default. + $whereClause = ['active' => 1]; + if (!$activeOnly) { + $whereClause = []; + } + $comment->update($whereClause); + return $comment; + } + + public function delete($comment) { + $comment->text = trans('entities.comment_deleted'); + $comment->html = trans('entities.comment_deleted'); + $comment->active = false; + $userId = user()->id; + $comment->updated_by = $userId; $comment->save(); return $comment; }