protected function normalizeAsArray($objects) : array
    {
        $key = $this->relation;

        if (!is_array($objects) && !$objects instanceof Collection) {
            throw new MappingException("column '$key' should be of type array or collection");
        }

        if ($objects instanceof Collection) {
            $objects = $objects->all();
        }

        $normalizedObjects = [];

        foreach ($objects as $object) {
            $wrapper = $this->factory->make($object);
            $normalizedObjects[] = $wrapper->getEntityAttributes();
        }

        if ($this->asJson) {
            $normalizedObjects = json_encode($normalizedObjects);
        }

        return [$key => $normalizedObjects];
    }
protected function normalizeAsArray($objects) : array
    {
        $key = $this->relation;

        if (!is_array($objects) && !$objects instanceof Collection) {
            throw new MappingException("column '$key' should be of type array or collection");
        }

        if ($objects instanceof Collection) {
            $objects = $objects->all();
        }

        $normalizedObjects = [];

        foreach ($objects as $object) {
            $wrapper = $this->factory->make($object);
            $normalizedObjects[] = $wrapper->getEntityAttributes();
        }

        if ($this->asJson) {
            $normalizedObjects = json_encode($normalizedObjects);
        }

        return [$key => $normalizedObjects];
    }
protected function normalizeAsArray ( $ objects ) : array { $ key = $ this -> relation ; if ( ! is_array ( $ objects ) && ! $ objects instanceof Collection ) { throw new MappingException ( "column '$key' should be of type array or collection" ) ; } if ( $ objects instanceof Collection ) { $ objects = $ objects -> all ( ) ; } $ normalizedObjects = [ ] ; foreach ( $ objects as $ object ) { $ wrapper = $ this -> factory -> make ( $ object ) ; $ normalizedObjects [ ] = $ wrapper -> getEntityAttributes ( ) ; } if ( $ this -> asJson ) { $ normalizedObjects = json_encode ( $ normalizedObjects ) ; } return [ $ key => $ normalizedObjects ] ; }
Normalize object as array containing raw attributes.

@param mixed $objects

@throws MappingException

@return array
Normalize object as array containing raw attributes .