|
1 | 1 | <?php namespace GeneaLabs\LaravelModelCaching\Traits;
|
2 | 2 |
|
3 |
| -use Illuminate\Container\Container; |
| 3 | +use Illuminate\Pagination\Paginator; |
4 | 4 |
|
5 | 5 | /**
|
6 | 6 | * @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
@@ -29,6 +29,17 @@ public function count($columns = "*")
|
29 | 29 | return $this->cachedValue(func_get_args(), $cacheKey);
|
30 | 30 | }
|
31 | 31 |
|
| 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 | + |
32 | 43 | public function decrement($column, $amount = 1, array $extra = [])
|
33 | 44 | {
|
34 | 45 | $this->cache($this->makeCacheTags())
|
@@ -117,7 +128,7 @@ public function insert(array $values)
|
117 | 128 | if (property_exists($this, "model")) {
|
118 | 129 | $this->checkCooldownAndFlushAfterPersisting($this->model);
|
119 | 130 | }
|
120 |
| - |
| 131 | + |
121 | 132 | return parent::insert($values);
|
122 | 133 | }
|
123 | 134 |
|
@@ -153,11 +164,7 @@ public function paginate(
|
153 | 164 | return parent::paginate($perPage, $columns, $pageName, $page);
|
154 | 165 | }
|
155 | 166 |
|
156 |
| - $page = Container::getInstance() |
157 |
| - ->make("request") |
158 |
| - ->input($pageName) |
159 |
| - ?: $page |
160 |
| - ?: 1; |
| 167 | + $page = $page ?: Paginator::resolveCurrentPage($pageName); |
161 | 168 |
|
162 | 169 | if (is_array($page)) {
|
163 | 170 | $page = $this->recursiveImplodeWithKey($page);
|
|
0 commit comments