Skip to content

Firefly III: a personal finances manager

Add some extra filters [skip ci]

James Coled6e2d8e4a2c0
diff --git a/app/Support/Binder/AccountList.php b/app/Support/Binder/AccountList.php
index 29cfd8e7ea..586d4ff8f4 100644
--- a/app/Support/Binder/AccountList.php
+++ b/app/Support/Binder/AccountList.php
@@ -37,6 +37,9 @@ class AccountList implements BinderInterface
if (Auth::check()) {
$ids = explode(',', $value);
+ // filter ids:
+ $ids = self::filterIds($ids);
+
/** @var \Illuminate\Support\Collection $object */
$object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
->where('account_types.editable', 1)
@@ -49,4 +52,22 @@ class AccountList implements BinderInterface
}
throw new NotFoundHttpException;
}
+
+ /**
+ * @param array $ids
+ *
+ * @return array
+ */
+ protected static function filterIds(array $ids): array
+ {
+ $new = [];
+ foreach ($ids as $id) {
+ if (intval($id) > 0) {
+ $new[] = $id;
+ }
+ }
+ $new = array_unique($new);
+
+ return $new;
+ }
}