Skip to content

hasOne & hasMany not working with foreignKey in ObjectId #1253

Closed
@motor-ua

Description

@motor-ua

hasOne & hasMany not working with foreignKey in ObjectId

Example:

User {
_id: ObjectId('dfsfasdhfj4252345hasdjklfsdf')
name: 'Alex'
}
Sale {
_id: ObjectId('asdfasdf8789a7sdf9adfasf'),
idUser: ObjectId('dfsfasdhfj4252345hasdjklfsdf')
}

in User class:

public function sales()
{
    return $this->hasMany(Sale::class, 'idUser', '_id');
}

and

$user->sales

result: []

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions