I am a nodejs developer an use waterline ORM in which after selecting data through db query builder we can call a function of populate() and the resultant is if we have an entry in database with some foreign key, it automatically replaces id with the object of the relationship. I wanted to know if we can do the same in laravel ORM.
Example
Without populate()
{
"id":"1",
"content":"abc",
"user":"1"
}
With populate()
{
"id":"1",
"content":"abc",
"user": {
"id":1,
"name":"john",
"email":"someone@example.com"
}
}
Thank you for helping.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire