added helper functions

This commit is contained in:
Denis Duliçi
2020-06-08 23:09:43 +03:00
parent 1441a56908
commit 5e51b494d2
3 changed files with 22 additions and 9 deletions

View File

@ -133,7 +133,7 @@ class Contact extends Model
{
$amount = 0;
$collection = in_array($this->type, $this->getCustomerTypes()) ? 'invoices' : 'bills';
$collection = $this->isCustomer() ? 'invoices' : 'bills';
$this->$collection->whereNotIn('status', ['draft', 'cancelled', 'paid'])->each(function ($item) use (&$amount) {
$unpaid = $item->amount - $item->paid;