weixin_39869432
2020-12-27 14:58 阅读 1

Reply to Self?

How might I allow users to reply to themselves?

For instance, in my website I want to allow users to store information in their comments if they so desire, so that they can link to specific comments to share with other users. Just requiring them to edit the comment wouldn't be effective.

Comment: "Resources" - Reply: "Resource one: [link]" - Reply: "Resource two: [link]"

(On another note, permalinking individual comments should also be added)

该提问来源于开源项目:laravelista/comments

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

7条回答 默认 最新

  • weixin_39869432 weixin_39869432 2020-12-27 14:58

    (Title changed because I thought I had figured out how to allow replying to self and wanted to recycle the issue, but then realized I hadn't actually fixed anything.)

    点赞 评论 复制链接分享
  • weixin_39968995 weixin_39968995 2020-12-27 14:58

    You could change the guard for comments reply. See config reply-to-comment guard. Just set it to return true.

    P.S. Open a new issue for permalinkinh to comments or send a PR. I'm willing to implement this feature.

    点赞 评论 复制链接分享
  • weixin_39869432 weixin_39869432 2020-12-27 14:58

    We got it to work - thanks!

    [and gotcha, did so!: #110 ]

    点赞 评论 复制链接分享
  • weixin_39928993 weixin_39928993 2020-12-27 14:58

    I'm doing the same, but just opening the permission guard treats the reply when from the same user like a new comment, and doesn't indent as a reply. I'm struggling to find where the code indents a reply so that I can indent a user's reply to their own comment. Any suggestions?

    点赞 评论 复制链接分享
  • weixin_39928993 weixin_39928993 2020-12-27 14:58

    I found a hack solution by adding list HTML into the _comment.blade.php view as follows:

    
            {{-- Recursion for children --}}
            ($grouped_comments->has($comment->getKey()))
               <ul style="list-style: none;">
             ($grouped_comments[$comment->getKey()] as $child)
                <li> 
                    ('comments::_comment', [
                        'comment' => $child,
                        'reply' => true,
                        'grouped_comments' => $grouped_comments
                    ])
                    </li>
    
                </ul>
    
    

    Hope this helps someone else.

    点赞 评论 复制链接分享
  • weixin_39908985 weixin_39908985 2020-12-27 14:58

    hi! the solution is much simpler; in the file CommentPolicy, simply change

    
     public function reply($user, Comment $comment) : bool
        {
            return $user->getKey() != $comment->commenter_id;
        }
    }
    

    to

    
     public function reply($user, Comment $comment) : bool
        {
            return $user->getKey();
        }
    }
    

    or

    
     public function reply($user, Comment $comment) : bool
        {
            return true;
        }
    }
    
    点赞 评论 复制链接分享
  • weixin_39928993 weixin_39928993 2020-12-27 14:58

    Thanks Ne-wt, I reversed my changes and tried that, but no difference to the indenting. Went back to my markup hack for now.

    点赞 评论 复制链接分享

相关推荐