src/Traits/MicroServiceCacheTrait.php
protected function addAttributeCacheKeys(array &$cacheKeys, Cacheable $model)
    {
        // Add a cache key for each attribute marked as a cache key.
        foreach ($model->getAttributeCacheKeys() as $attributeCacheKey) {
            $origAttributeValue = $this->getOriginalCacheKeyValue($model, $attributeCacheKey);

            $attributesValues = [];
            if ($origAttributeValue != null) {
                array_push($attributesValues, $origAttributeValue);
            }

            array_push($attributesValues, $model->{$attributeCacheKey});

            foreach ($attributesValues as $attributeValue) {
                // If the attribute is a collection check each item value.
                if ($attributeValue instanceof Collection) {
                    $this->getCollectionAttributeCacheKeys($cacheKeys, $model, $attributeCacheKey, $attributeValue);
                } elseif (is_scalar($attributeValue)) {
                    // Otherwise just get the value.
                    $cacheKeys[] = implode(':', [$model->getTable(), $attributeCacheKey, $attributeValue]);
                }
            }
        }
    }
protected function addAttributeCacheKeys(array &$cacheKeys, Cacheable $model)
    {
        // Add a cache key for each attribute marked as a cache key.
        foreach ($model->getAttributeCacheKeys() as $attributeCacheKey) {
            $origAttributeValue = $this->getOriginalCacheKeyValue($model, $attributeCacheKey);

            $attributesValues = [];
            if ($origAttributeValue != null) {
                array_push($attributesValues, $origAttributeValue);
            }

            array_push($attributesValues, $model->{$attributeCacheKey});

            foreach ($attributesValues as $attributeValue) {
                // If the attribute is a collection check each item value.
                if ($attributeValue instanceof Collection) {
                    $this->getCollectionAttributeCacheKeys($cacheKeys, $model, $attributeCacheKey, $attributeValue);
                } elseif (is_scalar($attributeValue)) {
                    // Otherwise just get the value.
                    $cacheKeys[] = implode(':', [$model->getTable(), $attributeCacheKey, $attributeValue]);
                }
            }
        }
    }
protected function addAttributeCacheKeys ( array & $ cacheKeys , Cacheable $ model ) { // Add a cache key for each attribute marked as a cache key. foreach ( $ model -> getAttributeCacheKeys ( ) as $ attributeCacheKey ) { $ origAttributeValue = $ this -> getOriginalCacheKeyValue ( $ model , $ attributeCacheKey ) ; $ attributesValues = [ ] ; if ( $ origAttributeValue != null ) { array_push ( $ attributesValues , $ origAttributeValue ) ; } array_push ( $ attributesValues , $ model -> { $ attributeCacheKey } ) ; foreach ( $ attributesValues as $ attributeValue ) { // If the attribute is a collection check each item value. if ( $ attributeValue instanceof Collection ) { $ this -> getCollectionAttributeCacheKeys ( $ cacheKeys , $ model , $ attributeCacheKey , $ attributeValue ) ; } elseif ( is_scalar ( $ attributeValue ) ) { // Otherwise just get the value. $ cacheKeys [ ] = implode ( ':' , [ $ model -> getTable ( ) , $ attributeCacheKey , $ attributeValue ] ) ; } } } }
Add cache keys for each attribute of a given model.

@param array $cacheKeys
@param Cacheable $model
Add cache keys for each attribute of a given model .