我在Laravel控制器中有一个类似下面的查询,我正在使用它进行API开发。
return $post
->comments()
->join('translationCHN', function ($join) {
$join->on('comment.word_id', '=', 'translationCHN.word_id');
$join->on('comment.sentence_id', '=', 'translationCHN.sentence_id');
})
->get();
我正在获取JSON格式的输出。从这个查询中,我想得到不同的JSON对象密钥translationCHN
的结果。
那怎么办?
UPDATE
我得到如下输出
{
"id": 1,
"word_id": 1,
"verse_id": 1,
"arabic": "بِسْمِ اللَّهِ الرَّحْمٰنِ الرَّحِيمِ",
"bayan": "dfgsdfgdfgfdsg",
"mkhan": "fgdgdgdsfg",
"kathir": "dfgdgfdfds",
"taisir": "dfgfdsgdsfgs",
"mujib": "dfsfgdsfgdsgfds",
"indo_pak": "بِسۡمِ اللّٰہِ الرَّحۡمٰنِ الرَّحِیۡمِ ﴿۱﴾",
"kasir": "dfgdsgdsgsdfgsdf",
"fmazid": "khkhjkhhhhkgkxfxdx",
}
我想得到如下输出
{
"id": 1,
"word_id": 1,
"verse_id": 1,
"arabic": "بِسْمِ اللَّهِ الرَّحْمٰنِ الرَّحِيمِ",
"bayan": "dfgsdfgdfgfdsg",
"translationCHN": {
"mkhan": "fgdgdgdsfg",
"kathir": "dfgdgfdfds",
"taisir": "dfgfdsgdsfgs",
"mujib": "dfsfgdsfgdsgfds",
"indo_pak": "بِسۡمِ اللّٰہِ الرَّحۡمٰنِ الرَّحِیۡمِ ﴿۱﴾",
"kasir": "dfgdsgdsgsdfgsdf",
"fmazid": "khkhjkhhhhkgkxfxdx",
}
}