你好,开发人员,
我正在尝试实现jenssegers/laravel-mongodb
的embedMany关系我有两个收藏夹:
{
"_id": "5c865ea4257db43fe4007331",
"general_name": "MY_PROFILE",
"type": "public",
"points": 100,
"status": 1,
"translated": [
{
"con_lang": "US-EN",
"country_code": "US",
"language": "EN",
"text": "My Profile",
"description": "My Profile"
},
...
],
"updated_at": "2019-03-11T13:12:04.000Z",
"created_at": "2019-03-11T13:12:04.000Z"
}
{
"_id": "5c865ea3257db43fe40072b2",
"id": "STANDARD_EDUCATION",
"general_name": "STANDARD_EDUCATION",
"country_code": "US",
"order": 1,
"profile_section_id": "5c865ea4257db43fe4007331",
"profile_section": "My Profile",
"translated": [
{
"con_lang": "US-EN",
"text": "What is the highest level of education you have completed?",
"hint": null,
"mapping": {},
"answers": [
{
"precode": "1",
"text": "3rd Grade or less",
"mapping": {}
}
]
},
{...}
],
"updated_at": "2019-03-11T13:12:03.000Z",
"created_at": "2019-03-11T13:12:03.000Z"
}
在 ProfileSection 中,我已添加
public function questions()
{
return $this->embedsMany(ProfilerQuestions::class, '_id', 'profile_section_id');
}
如果我执行ProfileSection::find('5c865ea4257db43fe4007331')->questions
它返回给我带有仅一个属性的个人档案问题对象:5c865ea4257db43fe4007331
,即个人档案部分
我在访问问题对象之前尝试使用->with('questions)
像this
但这不起作用
我不知道问题是什么,肯定需要一些帮助。