Код: Выделить всё
$companies = Company::with(['customerRewards']) // This is the problem
->has('customerRewards')
->whereHas('customerRewards', function(Builder $q) use ($customer) {
$q->where('customer_id', $customer->id); // This works as expected
})
->get();
Подробнее здесь: https://stackoverflow.com/questions/782 ... ith-result
Мобильная версия