src/AbstractEloquentDataSource.php
protected function createChild($key)
    {
        $relation = $this->getValueOrRelationForKey($key);
        // if this is not a relation, then it's the actual value
        // returned by a method (like for example computed attributes)
        // so we just return it as the value

        if (!$relation instanceof Relation) {
            return $relation;
        }

        $this->supportedRelationOrThrow($key, $relation);

        // TODO we need to bind the relation to the datasource here
        $model = Rel::make($relation)->getChild();

        if (!$this->isEloquentObject($model)) {
            throw new \LogicException(sprintf(
                'newModelFromRelation should return an Eloquent Model/Collection, but returned a %s (parent: %s, key: %s, relation: %s)',
                get_type_class($model),
                get_type_class($this->getDelegatedStorage()), $key, get_type_class($relation)
            ));
        }

        return $model;
    }
protected function createChild($key)
    {
        $relation = $this->getValueOrRelationForKey($key);
        // if this is not a relation, then it's the actual value
        // returned by a method (like for example computed attributes)
        // so we just return it as the value

        if (!$relation instanceof Relation) {
            return $relation;
        }

        $this->supportedRelationOrThrow($key, $relation);

        // TODO we need to bind the relation to the datasource here
        $model = Rel::make($relation)->getChild();

        if (!$this->isEloquentObject($model)) {
            throw new \LogicException(sprintf(
                'newModelFromRelation should return an Eloquent Model/Collection, but returned a %s (parent: %s, key: %s, relation: %s)',
                get_type_class($model),
                get_type_class($this->getDelegatedStorage()), $key, get_type_class($relation)
            ));
        }

        return $model;
    }
protected function createChild ( $ key ) { $ relation = $ this -> getValueOrRelationForKey ( $ key ) ; // if this is not a relation, then it's the actual value // returned by a method (like for example computed attributes) // so we just return it as the value if ( ! $ relation instanceof Relation ) { return $ relation ; } $ this -> supportedRelationOrThrow ( $ key , $ relation ) ; // TODO we need to bind the relation to the datasource here $ model = Rel :: make ( $ relation ) -> getChild ( ) ; if ( ! $ this -> isEloquentObject ( $ model ) ) { throw new \ LogicException ( sprintf ( 'newModelFromRelation should return an Eloquent Model/Collection, but returned a %s (parent: %s, key: %s, relation: %s)' , get_type_class ( $ model ) , get_type_class ( $ this -> getDelegatedStorage ( ) ) , $ key , get_type_class ( $ relation ) ) ) ; } return $ model ; }
Caches a relation for later use.
Creates a new model in case of empty values.

We need to invoke this method for every field
we want to save later, no exception

@param $key
@param $model

@return mixed
Caches a relation for later use . Creates a new model in case of empty values .