Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Adding exists to Buildable
  • Loading branch information
Charlie Waddell committed Jun 30, 2021
commit 2ce3dfffb66d3fda51e3fdeb4b96868d37ef0c17
13 changes: 12 additions & 1 deletion src/Traits/Buildable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -117,7 +128,7 @@ public function insert(array $values)
if (property_exists($this, "model")) {
$this->checkCooldownAndFlushAfterPersisting($this->model);
}

return parent::insert($values);
}

Expand Down