weixin_39614657
weixin_39614657
2020-12-09 07:55

nested comments

Hey, i have made comments also commentable to get nested comments.

i made comments commentable and i got them nested but i don't quite see a proper way to count the children of the comments on the number of the main model's comments...

i would do a

 
foreach ($model->comments as $comment) {
         $totalcomments += $comment->comments->count(); 
}

but i get an error about some trait, i guess there is a conflict between commentable and cancomment

该提问来源于开源项目:actuallymab/laravel-comment

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

7条回答

  • weixin_39614657 weixin_39614657 5月前

    Any news on this issue, mate?

    点赞 评论 复制链接分享
  • weixin_39995297 weixin_39995297 5月前

    Hi . First, thank you for your support & ping on this. I was unable to think this package as you mentioned, I will upgrade this package's version to 1.0.0 in a few days with this update.

    点赞 评论 复制链接分享
  • weixin_39614657 weixin_39614657 5月前

    Maybe i didnt explain well enough. Anyway this can get alot better and as soon as i get how to do it i will be happy to help on it. I am also thinking about a notification system: any user that comments on a model object can get notified of any new comment that is added to that model object (either that is a model object or a comment added to that model object).

    点赞 评论 复制链接分享
  • weixin_39995297 weixin_39995297 5月前

    Hi could you please check out this example? https://github.com/actuallymab/laravel-comment/blob/master/tests/CommentTest.php#L147

    Also, you can find a basic nested Comment object at https://github.com/actuallymab/laravel-comment/blob/master/tests/Models/Comment.php

    点赞 评论 复制链接分享
  • weixin_39614657 weixin_39614657 5月前

    Sorry, mate, i have no experience with tests. i don't know how to do tests yet.

    点赞 评论 复制链接分享
  • weixin_39995297 weixin_39995297 5月前

    You might seem that as an example.

    点赞 评论 复制链接分享
  • weixin_39995297 weixin_39995297 5月前

    If anything wrong or misunderstand, you can reopen issue.

    点赞 评论 复制链接分享

相关推荐