diff --git a/src/Traits/Buildable.php b/src/Traits/Buildable.php index 79e291a..ce14af5 100644 --- a/src/Traits/Buildable.php +++ b/src/Traits/Buildable.php @@ -29,6 +29,17 @@ public function count($columns = "*") return $this->cachedValue(func_get_args(), $cacheKey); } + public function exists() + { + if (! $this->isCachable()) { + return parent::exists(); + } + + $cacheKey = $this->makeCacheKey(['*'], null, "-exists"); + + return $this->cachedValue(func_get_args(), $cacheKey); + } + public function decrement($column, $amount = 1, array $extra = []) { $this->cache($this->makeCacheTags()) @@ -117,7 +128,7 @@ public function insert(array $values) if (property_exists($this, "model")) { $this->checkCooldownAndFlushAfterPersisting($this->model); } - + return parent::insert($values); }