I figured it out. I had to use a raw query, but it works:
$people = $people->whereHas('charges', function($q)
{
$q->havingRaw('SUM(amount) > ?', array($inputAmount));
}) ;
The havingRaw part is crucial, whereRaw does not work on aggregate operations like sum().
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community