I have an
Invoice model which has an
Invoice has related
$invoice->payments), which each also have amounts.
I want to run a query to show the
Invoices that are not yet fully paid off.
I would like to do this in a single query, because I have thousands of invoices, with possibly tens of payments each.
I know I can get the sum for each
But I don't know how I can tie this into a global query:
$openInvoices = Invoice::where('amount' < ...); ``` Is this possible with an eloquent query?