I'm not sure how to describe it will more clearly.

$builder = $this->modelsManager->createBuilder()->from('Courses');
$builder->join('Teachers');

And now I want to get this result when I turn it to JSON or Array.

[
  {"course_name": "xxx",
    "other_column": "xxx",
    "teachers": [
      {"id": 1, "name": "teacher1"},
      {"id": 2, "name": "teacher2"}
    ]
  }
]

But I only can math one teacher, and using group by I only can get one teacher.

Is there have any way let me get this result, or I just write a new model method to implement it?