Skip to content

Commit 53b684d

Browse files
author
Rob
committed
Add Builder orders to Cachable Key
1 parent ce2f023 commit 53b684d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/CachedBuilder.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ protected function getCacheKey(array $columns = ['*'], $idColumn = null) : strin
2727
$key .= $this->getQueryColumns($columns);
2828
$key .= $this->getWhereClauses();
2929
$key .= $this->getWithModels();
30+
$key .= $this->getOrderClauses();
3031
$key .= $this->getOffsetClause();
3132
$key .= $this->getLimitClause();
3233

@@ -117,6 +118,16 @@ protected function getWithModels() : string
117118
return '-' . implode('-', $eagerLoads->keys()->toArray());
118119
}
119120

121+
protected function getOrderClauses(){
122+
$orders = collect($this->query->orders);
123+
124+
return $orders->reduce(function($carry, $order){
125+
$carry .= '_sort_' . array_get($order, 'column') . '_' . array_get($order, 'direction');
126+
127+
return $carry;
128+
});
129+
}
130+
120131
protected function getCacheTags() : array
121132
{
122133
return collect($this->eagerLoad)->keys()

0 commit comments

Comments
 (0)