Closed QBLes closed 3 years ago
This should do:
$post->comments->where('child_id', '')->count();
or
$post->approvedComments->where('child_id', '')->count();
See https://github.com/laravelista/comments/blob/master/resources/views/components/comments.blade.php for reference.
wow so simple, this is why i love this package, Thanks heaps
Might be a stupid question but is there an easy way to get the users name (username in my case) as well? for example i used the following on a show all posts page so shows comment count for each post but i also need next to use "created_at" and Username of the comment.. Thanks champion
Instead of sending you the answer I am sending you a place where to look for stuff like that:
https://github.com/laravelista/comments/blob/master/src/Comment.php#L57
Sorry, still learning Laravel and how models and such work.. im not the most smartest cookie in the gorup lol
You'll get there. Just keep trying <3
Thanks bud!
Is there a way to use say $post->comments->count() but not have it count the "child comments/replies" only the main comments?
Thanks, Les