@@ -52,11 +52,11 @@ |
||
52 | 52 | $class = get_called_class(); |
53 | 53 | $instance = new $class; |
54 | 54 | |
55 | - return parent::all($columns); |
|
55 | + return parent::all($columns); |
|
56 | 56 | |
57 | - if (!$instance->isCachable()) { |
|
58 | - return parent::all($columns); |
|
59 | - } |
|
57 | + if (!$instance->isCachable()) { |
|
58 | + return parent::all($columns); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | $tags = $instance->makeCacheTags(); |
62 | 62 | $key = $instance->makeCacheKey(); |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | |
65 | 65 | if ($seconds > 0) { |
66 | 66 | return $instance->cache($tags) |
67 | - ->remember($key, $seconds, function () use ($columns) { |
|
67 | + ->remember($key, $seconds, function() use ($columns) { |
|
68 | 68 | return parent::all($columns); |
69 | 69 | }); |
70 | 70 | } |
71 | 71 | |
72 | 72 | return $instance->cache($tags) |
73 | - ->rememberForever($key, function () use ($columns) { |
|
73 | + ->rememberForever($key, function() use ($columns) { |
|
74 | 74 | return parent::all($columns); |
75 | 75 | }); |
76 | 76 | } |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function bootCachable() |
82 | 82 | { |
83 | - static::created(function ($instance) { |
|
83 | + static::created(function($instance) { |
|
84 | 84 | $instance->checkCooldownAndFlushAfterPersisting($instance); |
85 | 85 | }); |
86 | 86 | |
87 | - static::deleted(function ($instance) { |
|
87 | + static::deleted(function($instance) { |
|
88 | 88 | $instance->checkCooldownAndFlushAfterPersisting($instance); |
89 | 89 | }); |
90 | 90 | |
91 | - static::saved(function ($instance) { |
|
91 | + static::saved(function($instance) { |
|
92 | 92 | $instance->checkCooldownAndFlushAfterPersisting($instance); |
93 | 93 | }); |
94 | 94 | |
@@ -97,15 +97,15 @@ discard block |
||
97 | 97 | // $instance->checkCooldownAndFlushAfterPersisting($instance); |
98 | 98 | // }); |
99 | 99 | |
100 | - static::pivotAttached(function ($instance, $secondInstance, $relationship) { |
|
100 | + static::pivotAttached(function($instance, $secondInstance, $relationship) { |
|
101 | 101 | $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship); |
102 | 102 | }); |
103 | 103 | |
104 | - static::pivotDetached(function ($instance, $secondInstance, $relationship) { |
|
104 | + static::pivotDetached(function($instance, $secondInstance, $relationship) { |
|
105 | 105 | $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship); |
106 | 106 | }); |
107 | 107 | |
108 | - static::pivotUpdated(function ($instance, $secondInstance, $relationship) { |
|
108 | + static::pivotUpdated(function($instance, $secondInstance, $relationship) { |
|
109 | 109 | $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship); |
110 | 110 | }); |
111 | 111 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function newEloquentBuilder($query) |
129 | 129 | { |
130 | - if (! $this->isCachable()) { |
|
130 | + if (!$this->isCachable()) { |
|
131 | 131 | $this->isCachable = false; |
132 | 132 | |
133 | 133 | return new EloquentBuilder($query); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | EloquentBuilder $query, |
196 | 196 | int $seconds = null |
197 | 197 | ) : EloquentBuilder { |
198 | - if (! $seconds) { |
|
198 | + if (!$seconds) { |
|
199 | 199 | $seconds = $this->cacheCooldownSeconds; |
200 | 200 | } |
201 | 201 | |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:seconds"; |
205 | 205 | |
206 | 206 | $this->cache() |
207 | - ->rememberForever($cacheKey, function () use ($seconds) { |
|
207 | + ->rememberForever($cacheKey, function() use ($seconds) { |
|
208 | 208 | return $seconds; |
209 | 209 | }); |
210 | 210 | |
211 | 211 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at"; |
212 | 212 | $this->cache() |
213 | - ->rememberForever($cacheKey, function () { |
|
213 | + ->rememberForever($cacheKey, function() { |
|
214 | 214 | return (new Carbon)->now(); |
215 | 215 | }); |
216 | 216 |
@@ -295,17 +295,17 @@ |
||
295 | 295 | $seconds = $this->getCachingTime(); |
296 | 296 | |
297 | 297 | if ($seconds > 0) { |
298 | - return $this->cache($cacheTags) |
|
299 | - ->remember( |
|
300 | - $hashedCacheKey, |
|
301 | - $seconds, |
|
302 | - function () use ($arguments, $cacheKey, $method) { |
|
303 | - return [ |
|
304 | - "key" => $cacheKey, |
|
305 | - "value" => parent::{$method}(...$arguments), |
|
306 | - ]; |
|
307 | - } |
|
308 | - ); |
|
298 | + return $this->cache($cacheTags) |
|
299 | + ->remember( |
|
300 | + $hashedCacheKey, |
|
301 | + $seconds, |
|
302 | + function () use ($arguments, $cacheKey, $method) { |
|
303 | + return [ |
|
304 | + "key" => $cacheKey, |
|
305 | + "value" => parent::{$method}(...$arguments), |
|
306 | + ]; |
|
307 | + } |
|
308 | + ); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | return $this->cache($cacheTags) |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | { |
10 | 10 | public function avg($column) |
11 | 11 | { |
12 | - if (! $this->isCachable()) { |
|
12 | + if (!$this->isCachable()) { |
|
13 | 13 | return parent::avg($column); |
14 | 14 | } |
15 | 15 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | public function count($columns = "*") |
22 | 22 | { |
23 | - if (! $this->isCachable()) { |
|
23 | + if (!$this->isCachable()) { |
|
24 | 24 | return parent::count($columns); |
25 | 25 | } |
26 | 26 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | public function exists() |
33 | 33 | { |
34 | - if (! $this->isCachable()) { |
|
34 | + if (!$this->isCachable()) { |
|
35 | 35 | return parent::exists(); |
36 | 36 | } |
37 | 37 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function find($id, $columns = ["*"]) |
63 | 63 | { |
64 | - if (! $this->isCachable()) { |
|
64 | + if (!$this->isCachable()) { |
|
65 | 65 | return parent::find($id, $columns); |
66 | 66 | } |
67 | 67 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | public function first($columns = ["*"]) |
80 | 80 | { |
81 | - if (! $this->isCachable()) { |
|
81 | + if (!$this->isCachable()) { |
|
82 | 82 | return parent::first($columns); |
83 | 83 | } |
84 | 84 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | public function get($columns = ["*"]) |
100 | 100 | { |
101 | - if (! $this->isCachable()) { |
|
101 | + if (!$this->isCachable()) { |
|
102 | 102 | return parent::get($columns); |
103 | 103 | } |
104 | 104 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | public function max($column) |
136 | 136 | { |
137 | - if (! $this->isCachable()) { |
|
137 | + if (!$this->isCachable()) { |
|
138 | 138 | return parent::max($column); |
139 | 139 | } |
140 | 140 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | public function min($column) |
147 | 147 | { |
148 | - if (! $this->isCachable()) { |
|
148 | + if (!$this->isCachable()) { |
|
149 | 149 | return parent::min($column); |
150 | 150 | } |
151 | 151 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $pageName = "page", |
161 | 161 | $page = null |
162 | 162 | ) { |
163 | - if (! $this->isCachable()) { |
|
163 | + if (!$this->isCachable()) { |
|
164 | 164 | return parent::paginate($perPage, $columns, $pageName, $page); |
165 | 165 | } |
166 | 166 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $result = ""; |
181 | 181 | |
182 | 182 | foreach ($items as $key => $value) { |
183 | - $result .= $glue . $key . $glue . $value; |
|
183 | + $result .= $glue.$key.$glue.$value; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | return $result; |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | |
189 | 189 | public function pluck($column, $key = null) |
190 | 190 | { |
191 | - if (! $this->isCachable()) { |
|
191 | + if (!$this->isCachable()) { |
|
192 | 192 | return parent::pluck($column, $key); |
193 | 193 | } |
194 | 194 | |
195 | - $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : ""); |
|
195 | + $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : ""); |
|
196 | 196 | $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator); |
197 | 197 | |
198 | 198 | return $this->cachedValue(func_get_args(), $cacheKey); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | public function sum($column) |
202 | 202 | { |
203 | - if (! $this->isCachable()) { |
|
203 | + if (!$this->isCachable()) { |
|
204 | 204 | return parent::sum($column); |
205 | 205 | } |
206 | 206 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | public function value($column) |
222 | 222 | { |
223 | - if (! $this->isCachable()) { |
|
223 | + if (!$this->isCachable()) { |
|
224 | 224 | return parent::value($column); |
225 | 225 | } |
226 | 226 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | ->remember( |
300 | 300 | $hashedCacheKey, |
301 | 301 | $seconds, |
302 | - function () use ($arguments, $cacheKey, $method) { |
|
302 | + function() use ($arguments, $cacheKey, $method) { |
|
303 | 303 | return [ |
304 | 304 | "key" => $cacheKey, |
305 | 305 | "value" => parent::{$method}(...$arguments), |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | return $this->cache($cacheTags) |
312 | 312 | ->rememberForever( |
313 | 313 | $hashedCacheKey, |
314 | - function () use ($arguments, $cacheKey, $method) { |
|
314 | + function() use ($arguments, $cacheKey, $method) { |
|
315 | 315 | return [ |
316 | 316 | "key" => $cacheKey, |
317 | 317 | "value" => parent::{$method}(...$arguments), |
@@ -39,7 +39,7 @@ |
||
39 | 39 | protected function flushModelCache(string $option) : int |
40 | 40 | { |
41 | 41 | if (substr($option, 0, 9) == 'AppModels') { |
42 | - $option = 'App\Models\\' . substr($option, 9); |
|
42 | + $option = 'App\Models\\' . substr($option, 9); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $model = new $option; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | { |
14 | 14 | $option = $this->option('model'); |
15 | 15 | |
16 | - if (! $option) { |
|
16 | + if (!$option) { |
|
17 | 17 | return $this->flushEntireCache(); |
18 | 18 | } |
19 | 19 | |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | protected function flushModelCache(string $option) : int |
40 | 40 | { |
41 | 41 | if (substr($option, 0, 9) == 'AppModels') { |
42 | - $option = 'App\Models\\' . substr($option, 9); |
|
42 | + $option = 'App\Models\\'.substr($option, 9); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $model = new $option; |
46 | 46 | $usesCachableTrait = $this->getAllTraitsUsedByClass($option) |
47 | 47 | ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable"); |
48 | 48 | |
49 | - if (! $usesCachableTrait) { |
|
49 | + if (!$usesCachableTrait) { |
|
50 | 50 | $this->error("'{$option}' is not an instance of CachedModel."); |
51 | 51 | $this->line("Only CachedModel instances can be flushed."); |
52 | 52 |