Found the solution:
$customers = Customer::all();
$customers->each(function($customer) {
$customer->bills = $customer->bills->filter(function($bill) {
if($bill->foo == 'bar')
return true;
return false;
})
});
Hmm... I think it would be better to do the filtering within the model (either customers or bills, idk yet). But don't can figure out how to do that. Any ideas?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community