protected function fillRelated(
        $record,
        ResourceObject $resource,
        EncodingParametersInterface $parameters
    ) {
        $relationships = $resource->getRelationships();
        $changed = false;

        foreach ($relationships as $field => $value) {
            /** Skip any fields that are not fillable. */
            if ($this->isNotFillable($field, $record)) {
                continue;
            }

            /** Skip any fields that are not relations */
            if (!$this->isRelation($field)) {
                continue;
            }

            $relation = $this->getRelated($field);

            if ($this->requiresPrimaryRecordPersistence($relation)) {
                $relation->update($record, $value, $parameters);
                $changed = true;
            }
        }

        /** If there are changes, we need to refresh the model in-case the relationship has been cached. */
        if ($changed) {
            $record->refresh();
        }
    }
protected function fillRelated(
        $record,
        ResourceObject $resource,
        EncodingParametersInterface $parameters
    ) {
        $relationships = $resource->getRelationships();
        $changed = false;

        foreach ($relationships as $field => $value) {
            
            if ($this->isNotFillable($field, $record)) {
                continue;
            }

            
            if (!$this->isRelation($field)) {
                continue;
            }

            $relation = $this->getRelated($field);

            if ($this->requiresPrimaryRecordPersistence($relation)) {
                $relation->update($record, $value, $parameters);
                $changed = true;
            }
        }

        
        if ($changed) {
            $record->refresh();
        }
    }
protected function fillRelated ( $ record , ResourceObject $ resource , EncodingParametersInterface $ parameters ) { $ relationships = $ resource -> getRelationships ( ) ; $ changed = false ; foreach ( $ relationships as $ field => $ value ) { /** Skip any fields that are not fillable. */ if ( $ this -> isNotFillable ( $ field , $ record ) ) { continue ; } /** Skip any fields that are not relations */ if ( ! $ this -> isRelation ( $ field ) ) { continue ; } $ relation = $ this -> getRelated ( $ field ) ; if ( $ this -> requiresPrimaryRecordPersistence ( $ relation ) ) { $ relation -> update ( $ record , $ value , $ parameters ) ; $ changed = true ; } } /** If there are changes, we need to refresh the model in-case the relationship has been cached. */ if ( $ changed ) { $ record -> refresh ( ) ; } }
Hydrate related models after the primary record has been persisted.

@param Model $record
@param ResourceObject $resource
@param EncodingParametersInterface $parameters
Hydrate related models after the primary record has been persisted .