Добрый день.
У меня есть запрос:
$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
}
]
},
Как мне убрать ключи id_streets и id_management_company.
Связи:
public function streets(){
return $this->hasMany(Street::class, 'id_management_company');
}
public function houses()
{
return $this->hasMany(House::class, 'id_street');
}
Если добавляю в связи select без ключа, то тогда запрос не работает.