public static function createForEntity(ViewableContract $viewable, $period, bool $unique, string $collection = null): string
    {
        $cacheKey = config('eloquent-viewable.cache.key', 'cyrildewit.eloquent-viewable.cache');

        $viewableKey = $viewable->getKey();
        $viewableType = strtolower(str_replace('\\', '-', $viewable->getMorphClass()));

        $typeKey = $unique ? 'unique' : 'normal';
        $periodKey = static::createPeriodKey($period);

        $collection = $collection ? ".{$collection}" : '';

        return "{$cacheKey}{$collection}.{$viewableType}.{$viewableKey}.{$typeKey}.{$periodKey}";
    }
public static function createForEntity(ViewableContract $viewable, $period, bool $unique, string $collection = null): string
    {
        $cacheKey = config('eloquent-viewable.cache.key', 'cyrildewit.eloquent-viewable.cache');

        $viewableKey = $viewable->getKey();
        $viewableType = strtolower(str_replace('\\', '-', $viewable->getMorphClass()));

        $typeKey = $unique ? 'unique' : 'normal';
        $periodKey = static::createPeriodKey($period);

        $collection = $collection ? ".{$collection}" : '';

        return "{$cacheKey}{$collection}.{$viewableType}.{$viewableKey}.{$typeKey}.{$periodKey}";
    }
public static function createForEntity ( ViewableContract $ viewable , $ period , bool $ unique , string $ collection = null ) : string { $ cacheKey = config ( 'eloquent-viewable.cache.key' , 'cyrildewit.eloquent-viewable.cache' ) ; $ viewableKey = $ viewable -> getKey ( ) ; $ viewableType = strtolower ( str_replace ( '\\' , '-' , $ viewable -> getMorphClass ( ) ) ) ; $ typeKey = $ unique ? 'unique' : 'normal' ; $ periodKey = static :: createPeriodKey ( $ period ) ; $ collection = $ collection ? ".{$collection}" : '' ; return "{$cacheKey}{$collection}.{$viewableType}.{$viewableKey}.{$typeKey}.{$periodKey}" ; }
Create a unique key for the viewable model.

@param  \CyrildeWit\EloquentViewable\Contracts\Viewable  $viewable
@param  \CyrildeWit\EloquentViewable\Support\Period  $period
@param  bool  $unique
@return string
Create a unique key for the viewable model .