1 <?php namespace BookStack\Repos;
8 * @package BookStack\Repos
13 * @var Comment $comment
17 public function __construct(Comment $comment)
19 $this->comment = $comment;
22 public function create (Page $page, $data = []) {
24 $comment = $this->comment->newInstance();
25 $comment->fill($data);
27 $comment->page_id = $page->id;
28 $comment->created_by = $userId;
33 public function update($comment, $input) {
35 $comment->updated_by = $userId;
36 $comment->fill($input);
41 public function getCommentsForPage($pageId, $commentId, $count = 20) {
42 // requesting parent comments
43 $query = $this->comment->getCommentsByPage($pageId, $commentId);
44 return $query->paginate($count);
47 public function getCommentCount($pageId) {
48 return $this->comment->where('page_id', '=', $pageId)->count();