почему бы не сделать это ссылками на себя
сначала добавить parent_id
Schema::table('comments', function (Blueprint $table) {
$table->unsignedBigInteger('parent_id')->nullable();
});
тогда в вашем комментарии модель
public function parent()
{
return $this->belongsTo('App\Comment', 'parent_id');
}
public function replies()
{
return $this->hasMany('App\Comment', 'parent_id', 'id');
}
так что вы можете сделать что-то вроде этого
$comments = Comment::with('replies')->get();