From d6e2d8e4a2c0622219ff62add98babbb47b15502 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 2 Mar 2016 11:48:53 +0100 Subject: [PATCH] Add some extra filters [skip ci] --- app/Support/Binder/AccountList.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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; + } }