I have a FamilyMember model and a SubscriptionCharge model, SubscriptionCharge store charges of multiple months of each family member. I have to select members whos sum of charges greater than a specific amount.
$members=FamilyMember::whereHas('subscription_charge', function ($qq) {
$qq->where(); // how to check sum of column 'amount' in where
})->get();
How to check the sum of column 'amount' in a where condition