protected function toCollection($data)
    {
        if (is_array($data)) {
            return new Collection($data);
        } else {
            if (!($data instanceof Collection)) {
                // Invalid input type, return empty collection
                $data = new Collection();
            }
        }
        return $data;
    }