id) ->where('status', '<>', 'DRAFT'); return [ 'due_amount' => (clone $issuedInvoices)->sum('due_amount'), 'recentInvoices' => (clone $issuedInvoices)->take(5)->latest()->get(), 'recentEstimates' => Estimate::whereCustomer($customer->id) ->where('status', '<>', 'DRAFT') ->take(5) ->latest() ->get(), 'invoice_count' => (clone $issuedInvoices)->where('type', Invoice::TYPE_INVOICE)->count(), 'estimate_count' => Estimate::whereCustomer($customer->id) ->where('status', '<>', 'DRAFT') ->count(), 'payment_count' => Payment::whereCustomer($customer->id)->count(), ]; } }