protected function updatePivotIfDirty(string $pivotHash, string $relation)
    {
        $aggregate = $this->getRelatedAggregateFromHash($pivotHash, $relation);

        if ($aggregate->hasAttribute('pivot')) {
            $pivot = $aggregate->getEntityAttribute('pivot')->getEntityAttributes();

            $cachedPivotAttributes = $this->getPivotAttributesFromCache($pivotHash, $relation);

            $actualPivotAttributes = array_only($pivot, array_keys($cachedPivotAttributes));

            $dirty = $this->getDirtyAttributes($actualPivotAttributes, $cachedPivotAttributes);

            if (count($dirty) > 0) {
                $id = $aggregate->getEntityKeyValue();

                $this->entityMap->$relation($this->getEntityObject())->updateExistingPivot($id, $dirty);
            }
        }
    }
protected function updatePivotIfDirty(string $pivotHash, string $relation)
    {
        $aggregate = $this->getRelatedAggregateFromHash($pivotHash, $relation);

        if ($aggregate->hasAttribute('pivot')) {
            $pivot = $aggregate->getEntityAttribute('pivot')->getEntityAttributes();

            $cachedPivotAttributes = $this->getPivotAttributesFromCache($pivotHash, $relation);

            $actualPivotAttributes = array_only($pivot, array_keys($cachedPivotAttributes));

            $dirty = $this->getDirtyAttributes($actualPivotAttributes, $cachedPivotAttributes);

            if (count($dirty) > 0) {
                $id = $aggregate->getEntityKeyValue();

                $this->entityMap->$relation($this->getEntityObject())->updateExistingPivot($id, $dirty);
            }
        }
    }
protected function updatePivotIfDirty ( string $ pivotHash , string $ relation ) { $ aggregate = $ this -> getRelatedAggregateFromHash ( $ pivotHash , $ relation ) ; if ( $ aggregate -> hasAttribute ( 'pivot' ) ) { $ pivot = $ aggregate -> getEntityAttribute ( 'pivot' ) -> getEntityAttributes ( ) ; $ cachedPivotAttributes = $ this -> getPivotAttributesFromCache ( $ pivotHash , $ relation ) ; $ actualPivotAttributes = array_only ( $ pivot , array_keys ( $ cachedPivotAttributes ) ) ; $ dirty = $ this -> getDirtyAttributes ( $ actualPivotAttributes , $ cachedPivotAttributes ) ; if ( count ( $ dirty ) > 0 ) { $ id = $ aggregate -> getEntityKeyValue ( ) ; $ this -> entityMap -> $ relation ( $ this -> getEntityObject ( ) ) -> updateExistingPivot ( $ id , $ dirty ) ; } } }
Compare existing pivot record in cache and update it
if the pivot attributes are dirty.

@param string $pivotHash
@param string $relation

@return void
Compare existing pivot record in cache and update it if the pivot attributes are dirty .