Итак, он дает мне:
Код: Выделить всё
{
"success": true,
"data": [
[
"Question",
[
"Answer"
]
],
[
"Question",
[
"Answer 2"
]
],
[
"Question 2",
[
"Answer 3"
]
]
],
"message": null
И я хочу вернуть группу ответов на этот вопрос, например:
Код: Выделить всё
{
"success": true,
"data": [
[
"Question",
[
"Answer"
],
[
"Answer 2"
]
],
[
"Question 2",
[
"Answer 3"
]
]
],
"message": null
}
Код: Выделить всё
$questions = $this->getQRepository()->findAll();
$mappedQuestions = [];
foreach ($questions as $question){
$title = $question->getTitle();
$mappedQuestions[] = [
$title,
[
$question->getAnswer()
]
];
}
return $mappedQuestions;
Подробнее здесь: https://stackoverflow.com/questions/549 ... s-in-group
Мобильная версия