Skip to content

Commit 2184d07

Browse files
authored
Merge pull request #12 from RobMKR/master
Add Builder orders to Cachable Key
2 parents 54140af + 53b684d commit 2184d07

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: src/CachedBuilder.php

+11
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)