public function setAttributes(array $attributes)
    {
        $flattened = array_dot($attributes);

        $fields = $this->getFields();
        if (empty($fields))
            $fields = array_keys($attributes);

        foreach ($fields as $field) : 

            // make sure we have an aliased fields list
            $fillableKeys   = array_keys($this->fillable);
            $aliasedFields  = !empty($fillableKeys) && !is_integer($fillableKeys[0]);

            // read full path to attribute (get dot notation if available).
            $attribFullPath = isset($this->fillable[$field]) ? $this->fillable[$field] : $field;

            $hasByPath  = array_has($flattened, $attribFullPath);
            $hasByAlias = array_has($attributes, $field);

            if (! $hasByPath && ! $hasByAlias) {
                // try deep find and continue

                // browse attributes array in depth.
                $attrib = $attributes;
                foreach (explode(".", $attribFullPath) as $key) {
                    if (! isset($attrib[$key]))
                        $attrib[$key] = null;

                    $attrib = $attrib[$key];
                }

                $this->setAttribute($field, $attrib);
                continue;
            }

            // use attribute path or alias
            $attribValue = $hasByPath ? array_get($flattened, $attribFullPath)
                                      : array_get($attributes, $field);

            $this->setAttribute($field, $attribValue);
        endforeach ;

        return $this;
    }
public function setAttributes(array $attributes)
    {
        $flattened = array_dot($attributes);

        $fields = $this->getFields();
        if (empty($fields))
            $fields = array_keys($attributes);

        foreach ($fields as $field) : 

            // make sure we have an aliased fields list
            $fillableKeys   = array_keys($this->fillable);
            $aliasedFields  = !empty($fillableKeys) && !is_integer($fillableKeys[0]);

            // read full path to attribute (get dot notation if available).
            $attribFullPath = isset($this->fillable[$field]) ? $this->fillable[$field] : $field;

            $hasByPath  = array_has($flattened, $attribFullPath);
            $hasByAlias = array_has($attributes, $field);

            if (! $hasByPath && ! $hasByAlias) {
                // try deep find and continue

                // browse attributes array in depth.
                $attrib = $attributes;
                foreach (explode(".", $attribFullPath) as $key) {
                    if (! isset($attrib[$key]))
                        $attrib[$key] = null;

                    $attrib = $attrib[$key];
                }

                $this->setAttribute($field, $attrib);
                continue;
            }

            // use attribute path or alias
            $attribValue = $hasByPath ? array_get($flattened, $attribFullPath)
                                      : array_get($attributes, $field);

            $this->setAttribute($field, $attribValue);
        endforeach ;

        return $this;
    }
public function setAttributes ( array $ attributes ) { $ flattened = array_dot ( $ attributes ) ; $ fields = $ this -> getFields ( ) ; if ( empty ( $ fields ) ) $ fields = array_keys ( $ attributes ) ; foreach ( $ fields as $ field ) : // make sure we have an aliased fields list $ fillableKeys = array_keys ( $ this -> fillable ) ; $ aliasedFields = ! empty ( $ fillableKeys ) && ! is_integer ( $ fillableKeys [ 0 ] ) ; // read full path to attribute (get dot notation if available). $ attribFullPath = isset ( $ this -> fillable [ $ field ] ) ? $ this -> fillable [ $ field ] : $ field ; $ hasByPath = array_has ( $ flattened , $ attribFullPath ) ; $ hasByAlias = array_has ( $ attributes , $ field ) ; if ( ! $ hasByPath && ! $ hasByAlias ) { // try deep find and continue // browse attributes array in depth. $ attrib = $ attributes ; foreach ( explode ( "." , $ attribFullPath ) as $ key ) { if ( ! isset ( $ attrib [ $ key ] ) ) $ attrib [ $ key ] = null ; $ attrib = $ attrib [ $ key ] ; } $ this -> setAttribute ( $ field , $ attrib ) ; continue ; } // use attribute path or alias $ attribValue = $ hasByPath ? array_get ( $ flattened , $ attribFullPath ) : array_get ( $ attributes , $ field ) ; $ this -> setAttribute ( $ field , $ attribValue ) ; endforeach ; return $ this ; }
Setter for the `attributes` property.

This method uses a *dot notation* for attributes and resolves
relationships automatically when needed.

@internal
@return  \NEM\Contracts\DataTransferObject
Setter for the attributes property .