Add some extra filters [skip ci]

This commit is contained in:
James Cole 2016-03-02 11:48:53 +01:00
parent bbfc962727
commit d6e2d8e4a2

View File

@ -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;
}
}