Skip to content

Commit 6292bc9

Browse files
committed
Use data_get to retrieve bindings
1 parent ae3d1ec commit 6292bc9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/CacheKey.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,14 @@ protected function getValuesFromBindings(array $where, string $values) : string
176176
{
177177
// Fallback to this when the current binding does not exist in the bindings array
178178
$bindingFallback = __CLASS__ . ':UNKNOWN_BINDING';
179+
$currentBinding = $this->getCurrentBinding('where') ?? $bindingFallback;
179180

180-
if (($this->query->bindings["where"][$this->currentBinding] ?? $bindingFallback) !== $bindingFallback) {
181-
$values = $this->query->bindings["where"][$this->currentBinding];
181+
if ($currentBinding !== $bindingFallback) {
182+
$values = $currentBinding;
182183
$this->currentBinding++;
183184

184185
if ($where["type"] === "between") {
185-
$values .= "_" . $this->query->bindings["where"][$this->currentBinding];
186+
$values .= "_" . $this->getCurrentBinding('where');
186187
$this->currentBinding++;
187188
}
188189
}
@@ -237,7 +238,7 @@ protected function getInAndNotInClauses(array $where) : string
237238

238239
$type = strtolower($where["type"]);
239240
$subquery = $this->getValuesFromWhere($where);
240-
$values = collect($this->query->bindings["where"][$this->currentBinding] ?? []);
241+
$values = collect($this->getCurrentBinding('where') ?? []);
241242

242243
if (Str::startsWith($subquery, $values->first())) {
243244
$this->currentBinding += count($where["values"]);
@@ -298,7 +299,7 @@ protected function getRawClauses(array $where) : string
298299

299300
while (count($queryParts) > 1) {
300301
$clause .= "_" . array_shift($queryParts);
301-
$clause .= $this->query->bindings["where"][$this->currentBinding];
302+
$clause .= $this->getCurrentBinding('where');
302303
$this->currentBinding++;
303304
}
304305

@@ -365,4 +366,10 @@ protected function getBindingsSlug() : string
365366

366367
return Arr::query($this->model->query()->getBindings());
367368
}
369+
370+
371+
private function getCurrentBinding(string $type)
372+
{
373+
return data_get($this->query->bindings, "$type.$this->currentBinding");
374+
}
368375
}

0 commit comments

Comments
 (0)