From c8fcb4c959667541b781c3e997ce882b2cba3763 Mon Sep 17 00:00:00 2001 From: Lukas Halbritter Date: Thu, 20 Sep 2018 16:45:00 +0200 Subject: [PATCH] Added AccountType methods to get all types which are expediture or income. --- app/AccountType.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/AccountType.php b/app/AccountType.php index cb3f05e..f2089d1 100644 --- a/app/AccountType.php +++ b/app/AccountType.php @@ -25,4 +25,31 @@ class AccountType extends Model { return $this->accountClass->ioType(); } + + /* + * Get all account types which are expeditures. + * + * @return Illuminate\Database\Eloquent\Collection + */ + public static function expeditures() + { + return AccountType::whereHas('accountClass', function ($query) { + $query->whereHas('ioType', function ($query) { + $query->where('i_o_types.name', 'Ausgabe'); + }); + })->get(); + } + + /* + * Get all account types which are incomes. + * + * @return Illuminate\Database\Eloquent\Collection + */ + public static function incomes() { + return AccountType::whereHas('accountClass', function ($query) { + $query->whereHas('ioType', function ($query) { + $query->where('i_o_types.name', 'Einnahme'); + }); + })->get(); + } }