|
@@ -115,14 +115,18 @@ class Transaction extends Model
|
115
|
115
|
}
|
116
|
116
|
}
|
117
|
117
|
|
118
|
|
- public static function getBankAccountOptions(?int $excludedAccountId = null, ?int $currentBankAccountId = null): array
|
|
118
|
+ public static function getBankAccountOptions(?int $excludedAccountId = null, ?int $currentBankAccountId = null, bool $excludeArchived = true): array
|
119
|
119
|
{
|
120
|
120
|
return BankAccount::query()
|
121
|
|
- ->whereHas('account', function (Builder $query) {
|
122
|
|
- $query->where('archived', false);
|
|
121
|
+ ->whereHas('account', function (Builder $query) use ($excludeArchived) {
|
|
122
|
+ if ($excludeArchived) {
|
|
123
|
+ $query->where('archived', false);
|
|
124
|
+ }
|
123
|
125
|
})
|
124
|
|
- ->with(['account' => function ($query) {
|
125
|
|
- $query->where('archived', false);
|
|
126
|
+ ->with(['account' => function ($query) use ($excludeArchived) {
|
|
127
|
+ if ($excludeArchived) {
|
|
128
|
+ $query->where('archived', false);
|
|
129
|
+ }
|
126
|
130
|
}, 'account.subtype' => function ($query) {
|
127
|
131
|
$query->select(['id', 'name']);
|
128
|
132
|
}])
|