Skip to content
Merged
Changes from all 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
24 changes: 23 additions & 1 deletion src/CacheKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ 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;
}

Expand Down Expand Up @@ -101,6 +102,27 @@ protected function getCurrentBinding(string $type, $bindingFallback = null)
return data_get($this->query->bindings, "{$type}.{$this->currentBinding}", $bindingFallback);
}

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