From d7075c6f7a74bec87521d5d89f54ea40bf34cf82 Mon Sep 17 00:00:00 2001 From: Mike Bronner Date: Tue, 3 Oct 2017 11:56:18 -0700 Subject: [PATCH] Fix where clause parsing --- src/CachedBuilder.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/CachedBuilder.php b/src/CachedBuilder.php index 7166e50..fd073f8 100644 --- a/src/CachedBuilder.php +++ b/src/CachedBuilder.php @@ -35,6 +35,7 @@ protected function getCacheKey(array $columns = ['*'], $idColumn = null) : strin protected function getIdColumn(string $idColumn) : string { + return $idColumn ? "_{$idColumn}" : ''; } @@ -72,13 +73,20 @@ protected function getQueryColumns(array $columns) : string protected function getWhereClauses() : string { + // dump($this->query->wheres); return collect($this->query->wheres)->reduce(function ($carry, $where) { - $value = $where['value'] ?? implode('_', ($where['values'] ?? [])); - - if (! $value) { + if (! $where['column'] ?? false) { return $carry . ''; } + $value = $where['value'] ?? ''; + + if ($where['values'] ?? false) { + $value .= 'in_' . implode('_', $where['values']); + } + + $value = $where['type'] === 'Null' ? 'null' : $value; + return "{$carry}-{$where['column']}_{$value}"; }) ?: ''; }