protected function matchAsAttributes(array $attributes) : array
    {
        $attributesMap = $this->getAttributesDictionnary();

        // Get the subset that only the embedded object is concerned with and, convert it back
        // to embedded object attributes keys
        $originalAttributes = array_only($attributes, $attributesMap);

        $embeddedAttributes = [];

        foreach ($originalAttributes as $key => $value) {
            $embeddedKey = array_search($key, $attributesMap);
            $embeddedAttributes[$embeddedKey] = $value;
        }

        // Unset original attributes before, just in case one of the keys of the
        // original attributes is equals the relation name.
        foreach (array_keys($originalAttributes) as $key) {
            unset($attributes[$key]);
        }

        // Build object
        $attributes[$this->relation] = $this->buildEmbeddedObject($embeddedAttributes);

        return $attributes;
    }
protected function matchAsAttributes(array $attributes) : array
    {
        $attributesMap = $this->getAttributesDictionnary();

        // Get the subset that only the embedded object is concerned with and, convert it back
        // to embedded object attributes keys
        $originalAttributes = array_only($attributes, $attributesMap);

        $embeddedAttributes = [];

        foreach ($originalAttributes as $key => $value) {
            $embeddedKey = array_search($key, $attributesMap);
            $embeddedAttributes[$embeddedKey] = $value;
        }

        // Unset original attributes before, just in case one of the keys of the
        // original attributes is equals the relation name.
        foreach (array_keys($originalAttributes) as $key) {
            unset($attributes[$key]);
        }

        // Build object
        $attributes[$this->relation] = $this->buildEmbeddedObject($embeddedAttributes);

        return $attributes;
    }
protected function matchAsAttributes ( array $ attributes ) : array { $ attributesMap = $ this -> getAttributesDictionnary ( ) ; // Get the subset that only the embedded object is concerned with and, convert it back // to embedded object attributes keys $ originalAttributes = array_only ( $ attributes , $ attributesMap ) ; $ embeddedAttributes = [ ] ; foreach ( $ originalAttributes as $ key => $ value ) { $ embeddedKey = array_search ( $ key , $ attributesMap ) ; $ embeddedAttributes [ $ embeddedKey ] = $ value ; } // Unset original attributes before, just in case one of the keys of the // original attributes is equals the relation name. foreach ( array_keys ( $ originalAttributes ) as $ key ) { unset ( $ attributes [ $ key ] ) ; } // Build object $ attributes [ $ this -> relation ] = $ this -> buildEmbeddedObject ( $ embeddedAttributes ) ; return $ attributes ; }
Transform attributes from the parent entity result into
an embedded object, and return the updated attributes.

@param array $attributes

@return array
Transform attributes from the parent entity result into an embedded object and return the updated attributes .