src/UserBase.php
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;
    }
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;
    }
Check if the data is a Collection if an array convert it to a Collection

@param $data

@return Collection