@@ -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 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | $cachedList = $this->cachedList($limit, $cacheKey); |
18 | 18 | $visitsIds = $this->getVisitsIds($limit, $this->keys->visits, $isLow); |
19 | 19 | |
20 | - if($visitsIds === $cachedList->pluck('id')->toArray() && ! $this->fresh) { |
|
20 | + if ($visitsIds === $cachedList->pluck('id')->toArray() && !$this->fresh) { |
|
21 | 21 | return $cachedList; |
22 | 22 | } |
23 | 23 | |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | |
91 | 91 | return ($this->subject)::whereIn($this->keys->primary, $visitsIds) |
92 | 92 | ->get() |
93 | - ->sortBy(function ($subject) use ($visitsIds) { |
|
93 | + ->sortBy(function($subject) use ($visitsIds) { |
|
94 | 94 | return array_search($subject->{$this->keys->primary}, $visitsIds); |
95 | - })->each(function ($subject) use ($cacheKey) { |
|
95 | + })->each(function($subject) use ($cacheKey) { |
|
96 | 96 | $this->redis->rpush($cacheKey, serialize($subject)); |
97 | 97 | }); |
98 | 98 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function __get($attribute) |
79 | 79 | { |
80 | - if($this->keys->instanceOfModel && $relation = $this->subject->$attribute) { |
|
80 | + if ($this->keys->instanceOfModel && $relation = $this->subject->$attribute) { |
|
81 | 81 | $this->keys->append($attribute, $relation->{$relation->getKeyName()}); |
82 | 82 | } |
83 | 83 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function by($subject) |
92 | 92 | { |
93 | - if($subject instanceof Model) { |
|
93 | + if ($subject instanceof Model) { |
|
94 | 94 | $this->keys->append(strtolower(str_singular(class_basename(get_class($subject)))), |
95 | 95 | $subject->{$subject->getKeyName()}); |
96 | 96 | } else if (is_array($subject)) { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function recordedIp() |
125 | 125 | { |
126 | - return ! $this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX'); |
|
126 | + return !$this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX'); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -142,8 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | return intval( |
144 | 144 | (!$this->keys->instanceOfModel) ? |
145 | - $this->redis->get($this->keys->visits . '_total') : |
|
146 | - $this->redis->zscore($this->keys->visits, $this->keys->id) |
|
145 | + $this->redis->get($this->keys->visits . '_total') : $this->redis->zscore($this->keys->visits, $this->keys->id) |
|
147 | 146 | ); |
148 | 147 | } |
149 | 148 |