public function makeCollection(array $values, $class = null)
    {
        $collection = new Collection($values);
    
        if (!is_null($class) && class_exists($class)) {
            $model = new $class();
        
            if ($model instanceof Model) {
                foreach ($collection as $key => $item) {
                    $collection[$key] = $model->newInstance($item);
                }
            }
        }
    
        return $collection;
    }
public function makeCollection(array $values, $class = null)
    {
        $collection = new Collection($values);
    
        if (!is_null($class) && class_exists($class)) {
            $model = new $class();
        
            if ($model instanceof Model) {
                foreach ($collection as $key => $item) {
                    $collection[$key] = $model->newInstance($item);
                }
            }
        }
    
        return $collection;
    }
public function makeCollection ( array $ values , $ class = null ) { $ collection = new Collection ( $ values ) ; if ( ! is_null ( $ class ) && class_exists ( $ class ) ) { $ model = new $ class ( ) ; if ( $ model instanceof Model ) { foreach ( $ collection as $ key => $ item ) { $ collection [ $ key ] = $ model -> newInstance ( $ item ) ; } } } return $ collection ; }
Transform an array of values into a collection of models
@param array $values
@param null  $class
@return \Illuminate\Support\Collection
Transform an array of values into a collection of models