@@ -405,7 +405,7 @@ |
||
405 | 405 | $model = $this->getModel(); |
406 | 406 | |
407 | 407 | if ($model && $model->caching_time && $model->caching_time > 0) { |
408 | - return $model->caching_time; |
|
408 | + return $model->caching_time; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | $cachingTime = Container::getInstance() |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | protected function applyScopesToInstance() |
67 | 67 | { |
68 | 68 | if ( |
69 | - ! property_exists($this, "scopes") |
|
69 | + !property_exists($this, "scopes") |
|
70 | 70 | || $this->scopesAreApplied |
71 | 71 | || $this->withoutAllGlobalScopes |
72 | 72 | ) { |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | |
76 | 76 | foreach ($this->scopes as $identifier => $scope) { |
77 | 77 | if ( |
78 | - ! isset($this->scopes[$identifier]) |
|
78 | + !isset($this->scopes[$identifier]) |
|
79 | 79 | || isset($this->withoutGlobalScopes[$identifier]) |
80 | 80 | ) { |
81 | 81 | continue; |
82 | 82 | } |
83 | 83 | |
84 | - $this->callScope(function () use ($scope) { |
|
84 | + $this->callScope(function() use ($scope) { |
|
85 | 85 | if ($scope instanceof Closure) { |
86 | 86 | $scope($this); |
87 | 87 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at"; |
150 | 150 | |
151 | 151 | $this->cache() |
152 | - ->rememberForever($cacheKey, function () { |
|
152 | + ->rememberForever($cacheKey, function() { |
|
153 | 153 | return (new Carbon)->now(); |
154 | 154 | }); |
155 | 155 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function getModelCacheCooldown(Model $instance) : array |
242 | 242 | { |
243 | - if (! $instance->cacheCooldownSeconds) { |
|
243 | + if (!$instance->cacheCooldownSeconds) { |
|
244 | 244 | return [null, null, null]; |
245 | 245 | } |
246 | 246 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | [$cacheCooldown, $invalidatedAt, $savedAt] = $this |
250 | 250 | ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName); |
251 | 251 | |
252 | - if (! $cacheCooldown || $cacheCooldown === 0) { |
|
252 | + if (!$cacheCooldown || $cacheCooldown === 0) { |
|
253 | 253 | return [null, null, null]; |
254 | 254 | } |
255 | 255 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance); |
286 | 286 | |
287 | 287 | if ( |
288 | - ! $cacheCooldown |
|
288 | + !$cacheCooldown |
|
289 | 289 | || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown |
290 | 290 | ) { |
291 | 291 | return; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | { |
314 | 314 | [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance); |
315 | 315 | |
316 | - if (! $cacheCooldown) { |
|
316 | + if (!$cacheCooldown) { |
|
317 | 317 | $instance->flushCache(); |
318 | 318 | |
319 | 319 | if ($relationship) { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function isCachable() : bool |
345 | 345 | { |
346 | - $isCacheDisabled = ! Container::getInstance() |
|
346 | + $isCacheDisabled = !Container::getInstance() |
|
347 | 347 | ->make("config") |
348 | 348 | ->get("laravel-model-caching.enabled"); |
349 | 349 | $allRelationshipsAreCachable = true; |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | $allRelationshipsAreCachable = collect($this |
356 | 356 | ->eagerLoad) |
357 | 357 | ->keys() |
358 | - ->reduce(function ($carry, $related) { |
|
358 | + ->reduce(function($carry, $related) { |
|
359 | 359 | if ( |
360 | - ! method_exists($this->model, $related) |
|
360 | + !method_exists($this->model, $related) |
|
361 | 361 | || $carry === false |
362 | 362 | ) { |
363 | 363 | return $carry; |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | $relatedModel = $this->model->$related()->getRelated(); |
367 | 367 | |
368 | 368 | if ( |
369 | - ! method_exists($relatedModel, "isCachable") |
|
370 | - || ! $relatedModel->isCachable() |
|
369 | + !method_exists($relatedModel, "isCachable") |
|
370 | + || !$relatedModel->isCachable() |
|
371 | 371 | ) { |
372 | 372 | return false; |
373 | 373 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | } |
379 | 379 | |
380 | 380 | return $this->isCachable |
381 | - && ! $isCacheDisabled |
|
381 | + && !$isCacheDisabled |
|
382 | 382 | && $allRelationshipsAreCachable; |
383 | 383 | } |
384 | 384 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at"; |
393 | 393 | |
394 | 394 | $instance->cache() |
395 | - ->rememberForever($cacheKey, function () { |
|
395 | + ->rememberForever($cacheKey, function() { |
|
396 | 396 | return (new Carbon)->now(); |
397 | 397 | }); |
398 | 398 | } |
@@ -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 |