I have a topic that contain comments and each comment can contain replies. However, I want to optimize the way I count the total comments of each topics (comment + reply).
In my Topic model, I can optimally get the comment count using this syntax:
$this->comments()->count();
but since I have to get the replies, I have to iterate each comment so I can get the total value. This is not optimized because the custom attributes of the comments are also processed.
Is there any optimized way I can get the total comments and its replies from a topic without iterating each comments?