src/Utils/Transformers/WithCustomTransformers.php
function transform($models)
    {
        if($this instanceof SharpForm || $this instanceof Command) {
            // It's a Form (full entity or from a Command), there's only one model.
            // We must add Form Field Formatters in the process
            return $this->applyFormatters(
                $this->applyTransformers($models)
            );
        }

        // SharpEntityList case

        if($models instanceof LengthAwarePaginatorContract) {
            return new LengthAwarePaginator(
                $this->transform($models->items()),
                $models->total(),
                $models->perPage(),
                $models->currentPage()
            );
        }

        return collect($models)
            ->map(function($model) {
                return $this->applyTransformers($model);
            })
            ->all();
    }
function transform($models)
    {
        if($this instanceof SharpForm || $this instanceof Command) {
            // It's a Form (full entity or from a Command), there's only one model.
            // We must add Form Field Formatters in the process
            return $this->applyFormatters(
                $this->applyTransformers($models)
            );
        }

        // SharpEntityList case

        if($models instanceof LengthAwarePaginatorContract) {
            return new LengthAwarePaginator(
                $this->transform($models->items()),
                $models->total(),
                $models->perPage(),
                $models->currentPage()
            );
        }

        return collect($models)
            ->map(function($model) {
                return $this->applyTransformers($model);
            })
            ->all();
    }
function transform ( $ models ) { if ( $ this instanceof SharpForm || $ this instanceof Command ) { // It's a Form (full entity or from a Command), there's only one model. // We must add Form Field Formatters in the process return $ this -> applyFormatters ( $ this -> applyTransformers ( $ models ) ) ; } // SharpEntityList case if ( $ models instanceof LengthAwarePaginatorContract ) { return new LengthAwarePaginator ( $ this -> transform ( $ models -> items ( ) ) , $ models -> total ( ) , $ models -> perPage ( ) , $ models -> currentPage ( ) ) ; } return collect ( $ models ) -> map ( function ( $ model ) { return $ this -> applyTransformers ( $ model ) ; } ) -> all ( ) ; }
Transforms a model or a models collection into an array.

@param $models
@return array|LengthAwarePaginator
Transforms a model or a models collection into an array .