1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

#47 - Adds functionality to display child comments. Also has some code towards the reply functionality.

This commit is contained in:
Abijeet
2017-04-27 02:35:29 +05:30
parent d447355a61
commit c3ea0d333e
12 changed files with 127 additions and 34 deletions

View File

@ -34,8 +34,8 @@ class Comment extends Ownable
return $this->belongsTo(User::class);
}
public function getParentCommentsByPage($pageId, $pageNum = 0, $limit = 0) {
$data = ['pageId' => $pageId];
public function getCommentsByPage($pageId, $commentId, $pageNum = 0, $limit = 0) {
$query = static::newQuery();
$query->join('users AS u', 'comments.created_by', '=', 'u.id');
$query->leftJoin('users AS u1', 'comments.updated_by', '=', 'u1.id');
@ -44,7 +44,12 @@ class Comment extends Ownable
. 'u.name AS created_by_name, u1.name AS updated_by_name, '
. '(SELECT count(c.id) FROM bookstack.comments c WHERE c.parent_id = comments.id AND page_id = ?) AS cnt_sub_comments, i.url AS avatar ',
[$pageId]);
$query->whereRaw('page_id = ? AND parent_id IS NULL', [$pageId]);
if (empty($commentId)) {
$query->whereRaw('page_id = ? AND parent_id IS NULL', [$pageId]);
} else {
$query->whereRaw('page_id = ? AND parent_id = ?', [$pageId, $commentId]);
}
$query->orderBy('created_at');
return $query;
}