src/ExtendedPostProcessingRepository.php
public function postProcess($result)
    {
        // determine whether there is anything to process
        if (    is_null($result)
            ||  is_a($result, Collection::class) && $result->isEmpty()
        ) {
            return $result;
        }

        // check if there is anything to do process it through
        if ($this->postProcessors->isEmpty()) return $result;


        // for each Model, instantiate and apply the processors
        if (is_a($result, Collection::class)) {

            $result->transform(function ($model) {
                return $this->applyPostProcessorsToModel($model);
            });

        } elseif (is_a($result, AbstractPaginator::class)) {
            // result is paginate() result
            // do not apply postprocessing for now (how would we even do it?)
            return $result;

        } else {
            // result is a model
            $result = $this->applyPostProcessorsToModel($result);
        }

        return $result;
    }
public function postProcess($result)
    {
        // determine whether there is anything to process
        if (    is_null($result)
            ||  is_a($result, Collection::class) && $result->isEmpty()
        ) {
            return $result;
        }

        // check if there is anything to do process it through
        if ($this->postProcessors->isEmpty()) return $result;


        // for each Model, instantiate and apply the processors
        if (is_a($result, Collection::class)) {

            $result->transform(function ($model) {
                return $this->applyPostProcessorsToModel($model);
            });

        } elseif (is_a($result, AbstractPaginator::class)) {
            // result is paginate() result
            // do not apply postprocessing for now (how would we even do it?)
            return $result;

        } else {
            // result is a model
            $result = $this->applyPostProcessorsToModel($result);
        }

        return $result;
    }
public function postProcess ( $ result ) { // determine whether there is anything to process if ( is_null ( $ result ) || is_a ( $ result , Collection :: class ) && $ result -> isEmpty ( ) ) { return $ result ; } // check if there is anything to do process it through if ( $ this -> postProcessors -> isEmpty ( ) ) return $ result ; // for each Model, instantiate and apply the processors if ( is_a ( $ result , Collection :: class ) ) { $ result -> transform ( function ( $ model ) { return $ this -> applyPostProcessorsToModel ( $ model ) ; } ) ; } elseif ( is_a ( $ result , AbstractPaginator :: class ) ) { // result is paginate() result // do not apply postprocessing for now (how would we even do it?) return $ result ; } else { // result is a model $ result = $ this -> applyPostProcessorsToModel ( $ result ) ; } return $ result ; }
Runs the result for retrieval calls to the repository
through postprocessing.

@param Collection|Model|null $result the result of the query, ready for postprocessing
@return Model|Collection|null
Runs the result for retrieval calls to the repository through postprocessing .