public function assemble($document, Schema $schema)
    {
        $entityClass = $schema->entityClass;
        $model = Ioc::make($entityClass);

        foreach ($document as $field => $value) {
            $fieldType = $schema->fields[$field] ?? null;

            if ($fieldType && 'schema.' == substr($fieldType, 0, 7)) {
                $value = $this->assembleDocumentsRecursively($value, substr($fieldType, 7));
            }

            $model->$field = $value;
        }

        $entity = $this->morphingTime($model);

        return $this->prepareOriginalAttributes($entity);
    }
public function assemble($document, Schema $schema)
    {
        $entityClass = $schema->entityClass;
        $model = Ioc::make($entityClass);

        foreach ($document as $field => $value) {
            $fieldType = $schema->fields[$field] ?? null;

            if ($fieldType && 'schema.' == substr($fieldType, 0, 7)) {
                $value = $this->assembleDocumentsRecursively($value, substr($fieldType, 7));
            }

            $model->$field = $value;
        }

        $entity = $this->morphingTime($model);

        return $this->prepareOriginalAttributes($entity);
    }
public function assemble ( $ document , Schema $ schema ) { $ entityClass = $ schema -> entityClass ; $ model = Ioc :: make ( $ entityClass ) ; foreach ( $ document as $ field => $ value ) { $ fieldType = $ schema -> fields [ $ field ] ?? null ; if ( $ fieldType && 'schema.' == substr ( $ fieldType , 0 , 7 ) ) { $ value = $ this -> assembleDocumentsRecursively ( $ value , substr ( $ fieldType , 7 ) ) ; } $ model -> $ field = $ value ; } $ entity = $ this -> morphingTime ( $ model ) ; return $ this -> prepareOriginalAttributes ( $ entity ) ; }
Builds an object from the provided data.

@param array|object $document the attributes that will be used to compose the entity
@param Schema       $schema   schema that will be used to map each field

@return mixed
Builds an object from the provided data .