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
162862
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}";
    }
1254819
private function getCreatedPrimaryKey(Table $oldTable, Table $newTable)
    {
        if ((!$oldTable->hasPrimaryKey() && $newTable->hasPrimaryKey())
            || ($oldTable->hasPrimaryKey() && $newTable->hasPrimaryKey()
            && $this->comparePrimaryKeys($oldTable->getPrimaryKey(), $newTable->getPrimaryKey()))) {
            return $newTable->getPrimaryKey();
        }
    }
1082011
protected function _uniqueSlug(Entity $entity, $slug, $separator)
    {
        /** @var string $primaryKey */
        $primaryKey = $this->_table->getPrimaryKey();
        $field = $this->_table->aliasField($this->getConfig('field'));

        $conditions = $this->_conditions($entity, $slug);

        $i = 0;
        $suffix = '';
        $length = $this->getConfig('maxLength');

        while ($this->_table->exists($conditions)) {
            $i++;
            $suffix = $separator . $i;
            if ($length && $length < mb_strlen($slug . $suffix)) {
                $slug = mb_substr($slug, 0, $length - mb_strlen($suffix));
            }
            $conditions[$field] = $slug . $suffix;
        }

        return $slug . $suffix;
    }
905678
public function indexOf(Period $interval)
    {
        foreach ($this->intervals as $offset => $period) {
            if ($period->equals($interval)) {
                return $offset;
            }
        }

        return false;
    }
1023762
public function getUniqueDDL(Unique $unique)
    {
        $pattern = 'CONSTRAINT %s UNIQUE NONCLUSTERED (%s) ON [PRIMARY]';
        return sprintf($pattern,
            $this->quoteIdentifier($unique->getName()),
            $this->getColumnListDDL($unique->getColumnObjects())
        );
    }
1069587
public function withIssuerUniqueID(UniqueIdentifier $uid): self
    {
        $obj = clone $this;
        $obj->_issuerUniqueID = $uid;
        return $obj;
    }
133434
public function getModel($idSite, $period, $date, $segment = false)
    {
        $dataTable = $this->getDataTable('DevicesDetection_models', $idSite, $period, $date, $segment);

        $dataTable->filter(function (DataTable $table) {
            foreach ($table->getRowsWithoutSummaryRow() as $row) {

                $label = $row->getColumn('label');

                if (strpos($label, ';') !== false) {
                    list($brand, $model) = explode(';', $label, 2);
                    $brand = getDeviceBrandLabel($brand);
                } else {
                    $brand = null;
                    $model = $label;
                }

                $segment = sprintf('deviceBrand==%s;deviceModel==%s', urlencode($brand), urlencode($model));

                $row->setMetadata('segment', $segment);
            }
        });

        $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getModelName'));
        return $dataTable;
    }
1302901
public function period($period)
    {
        if (in_array($period, $this->periods)) {
            $this->keys->visits = $this->keys->period($period);
        }

        return $this;
    }
28963
public function refresh(Periode $periode)
    {
        $options = [];
        $coefficient = $periode->getCoefficient();
        $sessions = $periode->getCourseSessions();

        foreach ($sessions as $session) {
            $matiereId = $session->getId();
            $totalMatiere = $session->getTotal();
            $total = empty($totalMatiere) ? null : ceil($coefficient * $totalMatiere);
            $options[$matiereId] = [];
            $options[$matiereId]['total'] = $total;
            $options[$matiereId]['position'] = $session->getDisplayOrder();
        }

        $pemps = $this->getPempsByPeriode($periode);
        $this->om->startFlushSuite();

        foreach ($pemps as $pemp) {
            $matiereId = $pemp->getMatiere()->getId();

            if (isset($options[$matiereId])) {
                $pemp->setTotal($options[$matiereId]['total']);
                $pemp->setPosition($options[$matiereId]['position']);
                $this->om->persist($pemp);
            }
        }
        $this->om->endFlushSuite();

        $optionsDivers = [];
        $pointsDivers = $periode->getPointDivers();

        foreach ($pointsDivers as $divers) {
            $pointDiversId = $divers->getId();
            $totalDivers = $divers->getTotal();
            $total = empty($totalDivers) || !$divers->getWithTotal() ? null : ceil($coefficient * $totalDivers);
            $optionsDivers[$pointDiversId] = [];
            $optionsDivers[$pointDiversId]['total'] = $total;
            $optionsDivers[$pointDiversId]['position'] = $divers->getPosition();
        }
        $pepdps = $this->getPepdpsByPeriode($periode);
        $this->om->startFlushSuite();

        foreach ($pepdps as $pepdp) {
            $diversId = $pepdp->getDivers()->getId();

            if (isset($optionsDivers[$diversId])) {
                $pepdp->setTotal($optionsDivers[$diversId]['total']);
                $pepdp->setPosition($optionsDivers[$diversId]['position']);
                $this->om->persist($pepdp);
            }
        }
        $this->om->endFlushSuite();
    }
778325
protected function getFormattedSelection(ViewableData $record)
    {
        if ($format = $this->getFormatSelection()) {
            return SSViewer::fromString($format)->process($record);
        }
    }
189463
public static function periodDisplay($period, $year, $number, $length = 0)
    {
        $periodRange = $this->periodRange($period, $length);

        return $periodRange[$number] . ', ' . $year;
    }
586561
public function getCacheKeyForView($view, $key = null)
    {
        $parts = [$this->cacheKey, $view];

        if ($key !== null) {
            $parts[] = $key;
        }

        return implode('.', $parts);
    }
1287498
private function calculateUnion(Sequence $sequence, Period $period): Sequence
    {
        if ($sequence->isEmpty()) {
            $sequence->push($period);

            return $sequence;
        }

        $index = $sequence->count() - 1;
        $interval = $sequence->get($index);
        if ($interval->overlaps($period) || $interval->abuts($period)) {
            $sequence->set($index, $interval->merge($period));

            return $sequence;
        }

        $sequence->push($period);

        return $sequence;
    }
168244
protected function createSlide(ViewableData $item)
    {
        // Create Slide Object:
        
        $slide = Slide::create([
            'Title' => $item->MetaTitle,
            'ImageID' => $item->MetaImageID,
            'Caption' => $item->MetaImageCaption,
            'ParentID' => $this->ParentID,
            'HideImage' => $this->HideImage,
            'HideTitle' => $this->HideTitle,
            'HideCaption' => $this->HideCaption,
            'TitleAfterCaption' => $this->TitleAfterCaption
        ]);
        
        // Define Slide Link:
        
        $slide->LinkTo = LinkToExtension::MODE_URL;
        $slide->LinkURL = $item->MetaAbsoluteLink;
        $slide->LinkDisabled = $this->LinkDisabled;
        $slide->OpenLinkInNewTab = $this->OpenLinkInNewTab;
        
        // Answer Slide Object:
        
        return $slide;
    }
1328211
public function sameValueAs(Period $period)
	    {
	        return $this->start == $period->start && $this->end == $period->end;
	    }
1165008
public function setUniqueIDManager(IUniqueIDManager $uniqueIDManagerObject)
	{
		if(self::$_instance === NULL)
			throw new SonicRuntimeException('Sonic instance not initialized');
		
		if(!array_key_exists('sgoendoer\Sonic\Crypt\IUniqueIDManager', class_implements($uniqueIDManagerObject)))
		{
			throw new SonicRuntimeException('UniqueIDManager must implement sgoendoer\Sonic\Crypt\IUniqueIDManager');
		}
		else
			$this->uniqueIDManager = $uniqueIDManagerObject;
		
		return self::$_instance;
	}
484293
public function has($key, \DatePeriod $period = null)
    {
        if (is_null($period)) {
            return new Exists($this->repository->has($key));
        }

        return $this->hasForPeriod($key, $period);
    }