added custom transaction types

This commit is contained in:
Denis Duliçi
2020-08-26 15:14:16 +03:00
parent d64917a3e0
commit 68f31b895f
11 changed files with 115 additions and 23 deletions

View File

@ -3,9 +3,12 @@
namespace App\Models\Setting;
use App\Abstracts\Model;
use App\Traits\Transactions;
class Category extends Model
{
use Transactions;
protected $table = 'categories';
/**
@ -29,12 +32,12 @@ class Category extends Model
public function expense_transactions()
{
return $this->transactions()->where('type', 'expense');
return $this->transactions()->whereIn('type', (array) $this->getExpenseTypes());
}
public function income_transactions()
{
return $this->transactions()->where('type', 'income');
return $this->transactions()->whereIn('type', (array) $this->getIncomeTypes());
}
public function invoices()

View File

@ -3,9 +3,12 @@
namespace App\Models\Setting;
use App\Abstracts\Model;
use App\Traits\Contacts;
use App\Traits\Transactions;
class Currency extends Model
{
use Contacts, Transactions;
protected $table = 'currencies';
@ -40,17 +43,17 @@ class Currency extends Model
public function customers()
{
return $this->contacts()->where('type', 'customer');
return $this->contacts()->whereIn('type', (array) $this->getCustomerTypes());
}
public function expense_transactions()
{
return $this->transactions()->where('type', 'expense');
return $this->transactions()->whereIn('type', (array) $this->getExpenseTypes());
}
public function income_transactions()
{
return $this->transactions()->where('type', 'income');
return $this->transactions()->whereIn('type', (array) $this->getIncomeTypes());
}
public function invoices()
@ -65,7 +68,7 @@ class Currency extends Model
public function vendors()
{
return $this->contacts()->where('type', 'vendor');
return $this->contacts()->whereIn('type', (array) $this->getVendorTypes());
}
/**