diff --git a/src/CachedBuilder.php b/src/CachedBuilder.php index f01b59c..afb4e5d 100644 --- a/src/CachedBuilder.php +++ b/src/CachedBuilder.php @@ -27,6 +27,7 @@ protected function getCacheKey(array $columns = ['*'], $idColumn = null) : strin $key .= $this->getQueryColumns($columns); $key .= $this->getWhereClauses(); $key .= $this->getWithModels(); + $key .= $this->getOrderClauses(); $key .= $this->getOffsetClause(); $key .= $this->getLimitClause(); @@ -117,6 +118,16 @@ protected function getWithModels() : string return '-' . implode('-', $eagerLoads->keys()->toArray()); } + protected function getOrderClauses(){ + $orders = collect($this->query->orders); + + return $orders->reduce(function($carry, $order){ + $carry .= '_sort_' . array_get($order, 'column') . '_' . array_get($order, 'direction'); + + return $carry; + }); + } + protected function getCacheTags() : array { return collect($this->eagerLoad)->keys()