Skip to content

Commit 9881f1c

Browse files
authored
Merge pull request #405 from charlie-waddell/exists-missing-from-cached-builder
Adding exists to Buildable
2 parents 37cb150 + 2ce3dff commit 9881f1c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Traits/Buildable.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ public function count($columns = "*")
2929
return $this->cachedValue(func_get_args(), $cacheKey);
3030
}
3131

32+
public function exists()
33+
{
34+
if (! $this->isCachable()) {
35+
return parent::exists();
36+
}
37+
38+
$cacheKey = $this->makeCacheKey(['*'], null, "-exists");
39+
40+
return $this->cachedValue(func_get_args(), $cacheKey);
41+
}
42+
3243
public function decrement($column, $amount = 1, array $extra = [])
3344
{
3445
$this->cache($this->makeCacheTags())
@@ -117,7 +128,7 @@ public function insert(array $values)
117128
if (property_exists($this, "model")) {
118129
$this->checkCooldownAndFlushAfterPersisting($this->model);
119130
}
120-
131+
121132
return parent::insert($values);
122133
}
123134

0 commit comments

Comments
 (0)