- $this->checkOwnablePermission('page-view', $page);
- if (empty($commentId)) {
- // create a new comment.
- $this->checkPermission('comment-create-all');
- $comment = $this->commentRepo->create($page, $request->only(['text', 'html', 'parent_id']));
- $respMsg = trans('entities.comment_created');
- } else {
- // update existing comment
- // get comment by ID and check if this user has permission to update.
- $comment = $this->comment->findOrFail($commentId);
- $this->checkOwnablePermission('comment-update', $comment);
- $this->commentRepo->update($comment, $request->all());
- $respMsg = trans('entities.comment_updated');
- }
+ // Create a new comment.
+ $this->checkPermission('comment-create-all');
+ $comment = $this->commentRepo->create($page, $request->get('text'), $request->get('parent_id'));
+ Activity::add($page, 'commented_on', $page->book->id);
+ return view('comments.comment', ['comment' => $comment]);
+ }