mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
#47 - Adds functionality to delete a comment. Also reduces the number of watchers.
This commit is contained in:
@ -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('errors.cannot_add_comment_to_draft');
|
||||
$comment->html = trans('errors.cannot_add_comment_to_draft');
|
||||
$comment->active = false;
|
||||
$userId = user()->id;
|
||||
$comment->updated_by = $userId;
|
||||
$comment->save();
|
||||
return $comment;
|
||||
}
|
||||
|
Reference in New Issue
Block a user