You use get(['id'])
so Eloquent can't match loaded user(s) with relation parent - url. You need to select foreign key too:
get(['id','user_id']);
yes, that was a problem, here response:
{
"error": false,
"urls": [
{
"id": "3",
"user_id": "17",
"user": {
"id": "17",
"username": "firstuser"
}
},
{
"id": "4",
"user_id": "17",
"user": {
"id": "17",
"username": "firstuser"
}
}
]
}
@jarektkaczyk now i need implement some custom function to hide user_id ? right?
You can use $hidden
property on the model.
But I encourage you to use transformers when you output json, if that's the case.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community