Answer the question
In order to leave comments, you need to log in
How to remove extra keys from nested eager loading?
Good afternoon.
I have a query:
$company = $this->where('id', $id)->with('streets.houses')->first();
"id": 1,
"name": "fdg",
"phone": "gfdgfd",
"phone_director": "gdfgfd",
"address": "gfdgd",
"coordinates": "gfdg",
"created_at": "2017-09-06 11:15:23",
"updated_at": "2017-09-06 11:15:24",
"id_user": 44,
"streets": [
{
"id": 1,
"name": "sdfsdf",
"created_at": "2017-09-06 11:15:34",
"updated_at": "2017-09-06 11:15:34",
"id_management_company": 1,
"houses": [
{
"id": 1,
"name": "sdfdsf",
"created_at": "2017-09-06 11:15:53",
"updated_at": "2017-09-06 11:15:54",
"id_street": 1
},
{
"id": 2,
"name": "ghjhg",
"created_at": "2017-09-06 11:16:02",
"updated_at": "2017-09-06 11:16:02",
"id_street": 1
}
]
},
public function streets(){
return $this->hasMany(Street::class, 'id_management_company');
}
public function houses()
{
return $this->hasMany(House::class, 'id_street');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question