Skip to content

Commit fafa76f

Browse files
committed
Merge remote-tracking branch 'origin/master' into false-query-binding
2 parents 6292bc9 + 9881f1c commit fafa76f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Traits/Buildable.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php namespace GeneaLabs\LaravelModelCaching\Traits;
22

3-
use Illuminate\Container\Container;
3+
use Illuminate\Pagination\Paginator;
44

55
/**
66
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
@@ -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

@@ -153,11 +164,7 @@ public function paginate(
153164
return parent::paginate($perPage, $columns, $pageName, $page);
154165
}
155166

156-
$page = Container::getInstance()
157-
->make("request")
158-
->input($pageName)
159-
?: $page
160-
?: 1;
167+
$page = $page ?: Paginator::resolveCurrentPage($pageName);
161168

162169
if (is_array($page)) {
163170
$page = $this->recursiveImplodeWithKey($page);

0 commit comments

Comments
 (0)