@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! function_exists('visits')) |
|
3 | +if (!function_exists('visits')) |
|
4 | 4 | { |
5 | 5 | function visits($subject, $tag = 'visits') |
6 | 6 | { |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function register() |
27 | 27 | { |
28 | 28 | $this->mergeConfigFrom( |
29 | - __DIR__.'/config/visits.php', 'visits' |
|
29 | + __DIR__ . '/config/visits.php', 'visits' |
|
30 | 30 | ); |
31 | 31 | } |
32 | 32 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function __get($attribute) |
68 | 68 | { |
69 | - if($this->keys->instanceOfModel && $relation = $this->subject->$attribute) { |
|
69 | + if ($this->keys->instanceOfModel && $relation = $this->subject->$attribute) { |
|
70 | 70 | $this->keys->append($attribute, $relation->{$relation->getKeyName()}); |
71 | 71 | } |
72 | 72 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function by($subject) |
81 | 81 | { |
82 | - if($subject instanceof Model) { |
|
82 | + if ($subject instanceof Model) { |
|
83 | 83 | $this->keys->append(strtolower(str_singular(class_basename(get_class($subject)))), |
84 | 84 | $subject->{$subject->getKeyName()}); |
85 | 85 | } else if (is_array($subject)) { |
@@ -304,8 +304,7 @@ discard block |
||
304 | 304 | |
305 | 305 | return intval( |
306 | 306 | (!$this->keys->instanceOfModel) ? |
307 | - $this->redis->get($this->keys->visits . '_total') : |
|
308 | - $this->redis->zscore($this->keys->visits, $this->keys->id) |
|
307 | + $this->redis->get($this->keys->visits . '_total') : $this->redis->zscore($this->keys->visits, $this->keys->id) |
|
309 | 308 | ); |
310 | 309 | } |
311 | 310 | |
@@ -416,10 +415,10 @@ discard block |
||
416 | 415 | |
417 | 416 | return ($this->subject)::whereIn($this->keys->primary, $visitsIds) |
418 | 417 | ->get() |
419 | - ->sortBy(function ($subject) use ($visitsIds) { |
|
418 | + ->sortBy(function($subject) use ($visitsIds) { |
|
420 | 419 | return array_search($subject->{$this->keys->primary}, $visitsIds); |
421 | 420 | }) |
422 | - ->each(function ($subject) use ($cacheKey) { |
|
421 | + ->each(function($subject) use ($cacheKey) { |
|
423 | 422 | $this->redis->rpush($cacheKey, serialize($subject)); |
424 | 423 | }); |
425 | 424 | } |