protected function eagerLoadRelations($data, array $requested, $transformer)
    {
        $relations = collect(array_keys($requested))->reduce(function ($eagerLoads, $relation) use ($requested, $transformer) {
            $identifier = camel_case($this->stripParametersFromRelation($relation));

            if (method_exists($transformer, 'include' . ucfirst($identifier))) {
                return $eagerLoads;
            }

            return array_merge($eagerLoads, [$identifier => $requested[$relation] ?: function () { }]);
        }, []);

        $data->load($relations);
    }
protected function eagerLoadRelations($data, array $requested, $transformer)
    {
        $relations = collect(array_keys($requested))->reduce(function ($eagerLoads, $relation) use ($requested, $transformer) {
            $identifier = camel_case($this->stripParametersFromRelation($relation));

            if (method_exists($transformer, 'include' . ucfirst($identifier))) {
                return $eagerLoads;
            }

            return array_merge($eagerLoads, [$identifier => $requested[$relation] ?: function () { }]);
        }, []);

        $data->load($relations);
    }
protected function eagerLoadRelations ( $ data , array $ requested , $ transformer ) { $ relations = collect ( array_keys ( $ requested ) ) -> reduce ( function ( $ eagerLoads , $ relation ) use ( $ requested , $ transformer ) { $ identifier = camel_case ( $ this -> stripParametersFromRelation ( $ relation ) ) ; if ( method_exists ( $ transformer , 'include' . ucfirst ( $ identifier ) ) ) { return $ eagerLoads ; } return array_merge ( $ eagerLoads , [ $ identifier => $ requested [ $ relation ] ? : function ( ) { } ] ) ; } , [ ] ) ; $ data -> load ( $ relations ) ; }
Eager load all requested relations except the ones defined as an "include" method
in the transformers. We also strip away any parameters from the relation name
and normalize relations by swapping "null" constraints to empty closures.

@param  mixed                                                          $data
@param  array                                                          $requested
@param  \Flugg\Responder\Transformers\Transformer|callable|string|null $transformer
@return void
Eager load all requested relations except the ones defined as an include method in the transformers . We also strip away any parameters from the relation name and normalize relations by swapping null constraints to empty closures .