Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
composer.lock
.phpunit.result.cache
phpunit.xml
.idea
24 changes: 23 additions & 1 deletion src/CacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,39 @@ public function make(
$key .= $this->getIdColumn($idColumn ?: "");
$key .= $this->getQueryColumns($columns);
$key .= $this->getWhereClauses();
$key .= $this->getHavingClauses();
$key .= $this->getWithModels();
$key .= $this->getOrderByClauses();
$key .= $this->getOffsetClause();
$key .= $this->getLimitClause();
$key .= $this->getBindingsSlug();
$key .= $keyDifferentiator;
$key .= $this->macroKey;
// dump($key);

return $key;
}

protected function getHavingClauses()
{
return Collection::make($this->query->havings)->reduce(function ($carry, $having) {
$value = $carry;
$value .= $this->getHavingClause($having);

return $value;
});
}

protected function getHavingClause(array $having): string
{
$return = '-having';

foreach ($having as $key => $value) {
$return .= '_' . $key . '_' . str_replace(' ', '_', $value);
}

return $return;
}

protected function getIdColumn(string $idColumn) : string
{
return $idColumn ? "_{$idColumn}" : "";
Expand Down