Я выполняю красноречивый запрос, используя несколько with
.
Это запрос, который я выполняю:
$offers = \App\Offer::
with(['event_date.event.place.location'], ['event_date.event.theatre.prices'])
->whereHas('event_date', function ($query) use ($location_id) {
$query->where('events_dates.date', \Carbon\Carbon::today()->format('Y-m-d'));
if (!empty($location_id)) {
$query->whereHas('event', function ($query) use ($location_id) {
$query->whereHas('place', function ($query) use ($location_id) {
$query->where('places.location_id', $location_id);
});
});
}
})
->skip($skip)
->take($take)
->get();
Проблема в том, что я получаю только первое с предложением (event_date.event.place.location
),и не второй.
Мне кажется, проблема в том, что оба предложения with
имеют одинаковый корень (event_date.event
), но я не знаю, как его решить.
ОБНОВЛЕНО
Это JSON, который я получаю:
{
"data":[
{
"id":12,
...
"event_date":{
"id":1119,
"event_id":6,
"date":"2018-10-28 00:00:00",
...
"event":{
"id":6,
"title":"Evento di test ennesimo",
...
"place":{
"id":2,
...
"location":{
"id":2320,
"name":"Roma",
"code":null,
"root_id":29,
"lft":11910,
"rgt":11911,
"level":3
}
},
}
}
}
]
}
Как вы можете видеть, есть информация о записи event_date.event.place.location
, но не event_date.event.theatre.prices
.