-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
I have this objects stored on mongodb:
Client:
{
"_id" : ObjectId("581af4fbf53b09175210c2dc"),
"created_at" : ISODate("2016-11-03T08:27:39.675Z"),
"updated_at" : ISODate("2016-11-03T08:27:39.675Z"),
"url" : "francesco.ragusa.local",
"safe" : false,
"attributes" : [ ],
"enabled" : true,
"__v" : 0
}
MessageSender:
{
"_id" : ObjectId("581c583440135d1e581ec58e"),
"created_at" : ISODate("2016-11-04T09:43:16.639Z"),
"updated_at" : ISODate("2016-11-04T09:43:16.639Z"),
"owner" : ObjectId("581af4fbf53b09175210c2dc"),
"type" : {
"information" : null,
"name" : "operator"
},
"nickname" : "Giusipuzzu",
"enabled" : true,
"__v" : 0
}
And this classes on laravel:
class Client extends Eloquent
{
protected $connection = 'mongodb';
public function messageSenders(){
return $this->hasMany(\App\Models\MessageSender::class, 'owner');
}
}
class MessageSender extends Eloquent
{
protected $connection = 'mongodb';
public function client(){
return $this->belongsTo(\App\Models\Client::class, 'owner');
}
}
Where Eloquent is an alias of 'Jenssegers\Mongodb\Eloquent\Model'.
If I do:
MessageSender::find('581c583440135d1e581ec58e')->client
I got the right object.
But if I do:
Client::find('581af4fbf53b09175210c2dc')->messageSenders
I got a instance of 'Illuminate\Database\Eloquent\Collection' but empty.
I think hasMany relationship doesn't work properly.
Metadata
Metadata
Assignees
Labels
No labels