0
首先,我是laravel 5.0中使用jenssegers的laravel mongodb集合的新手。我想,以形成子集里收集像下面如何使用Laravel 5和mongodb创建子集合
{
"Uid": 1112,
"AccountNo": 7620424,
"Party": {
"LanguageCode": "en",
"Type": "individual",
"Contact": [
{
"id" : It will be mongo object id How to create?
"Type": "default",
"Person": {
"FullName": "Test Test"
},
{
"id" : It will be mongo object id How to create?
"Type": "default",
"Person": {
"FullName": "Test Test"
},
"MessagingMedium": [
{
"Id": It will be mongo object id How to create?
"Scheme": "mailto",
"URI": "[email protected]",
"Status": "awaiting.registration"
},
{
"Id": It will be mongo object id How to create?
"Scheme": "mailto",
"URI": "[email protected]",
"Status": "awaiting.registration"
}
]
}
]
},
}
我USERPROFILE模型
use Jenssegers\Mongodb\Model as Eloquent;
class UserProfile extends Eloquent {
protected $table = 'user_profile';
}
use Jenssegers\Mongodb\Model as Eloquent;
class Contact extends Eloquent {
protected $table = 'contact';
}
我一直试图尝试接触子集合添加到USERPROFILE集合创建像下面后创建的用户配置文件
$user = UserProfile::create(array('Uid' => $uId, 'AccountNo' => $accNo));
$card = Contact::create(['id' => 123]); //contact mongodb Eloquent
$card->userprofile()->save($card);
但其没有工作和收集也没有创造
那是正确的,我不知道abount的hasMany,embedsmany colleciton
任何人帮我出