protected function parseFilterInput(array $input)
    {
        if (count($input) === 0) {
            return [];
        }

        $allowed = [];
        $model = $this->model;

        if (property_exists($model, 'filterableProperties')) {
            $allowed = $model::$filterableProperties;
        }

        $filter = [];
        foreach ($input as $key => $value) {
            if (is_numeric($key) || !preg_match('/^[A-Za-z0-9_]*$/', $key)) {
                throw new InvalidRequest("Invalid filter parameter: $key");
            }

            // check if in the list of allowed filter properties
            if (!in_array($key, $allowed)) {
                throw new InvalidRequest("Invalid filter parameter: $key");
            }

            $filter[$key] = $value;
        }

        return $filter;
    }