@@ -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)) { |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $cachedList = $this->cachedList($limit, $cacheKey); |
| 234 | 234 | $visitsIds = $this->getVisits($limit, $this->keys->visits, $isLow); |
| 235 | 235 | |
| 236 | - if($visitsIds === $cachedList->pluck('id')->toArray() && ! $this->fresh) { |
|
| 236 | + if ($visitsIds === $cachedList->pluck('id')->toArray() && !$this->fresh) { |
|
| 237 | 237 | return $cachedList; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | public function recordedIp() |
| 290 | 290 | { |
| 291 | - return ! $this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX'); |
|
| 291 | + return !$this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX'); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -307,8 +307,7 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | return intval( |
| 309 | 309 | (!$this->keys->instanceOfModel) ? |
| 310 | - $this->redis->get($this->keys->visits . '_total') : |
|
| 311 | - $this->redis->zscore($this->keys->visits, $this->keys->id) |
|
| 310 | + $this->redis->get($this->keys->visits . '_total') : $this->redis->zscore($this->keys->visits, $this->keys->id) |
|
| 312 | 311 | ); |
| 313 | 312 | } |
| 314 | 313 | |
@@ -371,7 +370,7 @@ discard block |
||
| 371 | 370 | $this->redis->incrby($this->keys->visits . '_total', $inc); |
| 372 | 371 | |
| 373 | 372 | foreach (['country', 'refer', 'periods'] as $method) { |
| 374 | - $$method && $this->{'record'. studly_case($method)}($inc); |
|
| 373 | + $$method && $this->{'record' . studly_case($method)}($inc); |
|
| 375 | 374 | } |
| 376 | 375 | } |
| 377 | 376 | } |
@@ -431,9 +430,9 @@ discard block |
||
| 431 | 430 | |
| 432 | 431 | return ($this->subject)::whereIn($this->keys->primary, $visitsIds) |
| 433 | 432 | ->get() |
| 434 | - ->sortBy(function ($subject) use ($visitsIds) { |
|
| 433 | + ->sortBy(function($subject) use ($visitsIds) { |
|
| 435 | 434 | return array_search($subject->{$this->keys->primary}, $visitsIds); |
| 436 | - })->each(function ($subject) use ($cacheKey) { |
|
| 435 | + })->each(function($subject) use ($cacheKey) { |
|
| 437 | 436 | $this->redis->rpush($cacheKey, serialize($subject)); |
| 438 | 437 | }); |
| 439 | 438 | } |