@@ -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 | { |
@@ -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($this->keys->primary)->toArray() && ! $this->fresh) { |
|
| 20 | + if ($visitsIds === $cachedList->pluck($this->keys->primary)->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 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | protected function recordCountry($inc) |
| 13 | 13 | { |
| 14 | - $this->redis->zincrby($this->keys->visits."_countries:{$this->keys->id}", $inc, $this->getVisitorCountry()); |
|
| 14 | + $this->redis->zincrby($this->keys->visits . "_countries:{$this->keys->id}", $inc, $this->getVisitorCountry()); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | protected function recordRefer($inc) |
| 21 | 21 | { |
| 22 | 22 | $referer = app(Referer::class)->get(); |
| 23 | - $this->redis->zincrby($this->keys->visits."_referers:{$this->keys->id}", $inc, $referer); |
|
| 23 | + $this->redis->zincrby($this->keys->visits . "_referers:{$this->keys->id}", $inc, $referer); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | protected function recordOperatingSystem($inc) |
| 30 | 30 | { |
| 31 | - $this->redis->zincrby($this->keys->visits."_OSes:{$this->keys->id}", $inc, $this->getVisitorOperatingSystem()); |
|
| 31 | + $this->redis->zincrby($this->keys->visits . "_OSes:{$this->keys->id}", $inc, $this->getVisitorOperatingSystem()); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | protected function recordLanguage($inc) |
| 38 | 38 | { |
| 39 | - $this->redis->zincrby($this->keys->visits."_languages:{$this->keys->id}", $inc, $this->getVisitorLanguage()); |
|
| 39 | + $this->redis->zincrby($this->keys->visits . "_languages:{$this->keys->id}", $inc, $this->getVisitorLanguage()); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $periodKey = $this->keys->period($period); |
| 49 | 49 | |
| 50 | 50 | $this->redis->zincrby($periodKey, $inc, $this->keys->id); |
| 51 | - $this->redis->incrby($periodKey.'_total', $inc); |
|
| 51 | + $this->redis->incrby($periodKey . '_total', $inc); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -15,10 +15,10 @@ discard block |
||
| 15 | 15 | public function boot() |
| 16 | 16 | { |
| 17 | 17 | $this->publishes([ |
| 18 | - __DIR__.'/config/visits.php' => config_path('visits.php'), |
|
| 18 | + __DIR__ . '/config/visits.php' => config_path('visits.php'), |
|
| 19 | 19 | ], 'config'); |
| 20 | 20 | |
| 21 | - Carbon::macro('endOfxHours', function ($xhours) { |
|
| 21 | + Carbon::macro('endOfxHours', function($xhours) { |
|
| 22 | 22 | if ($xhours > 12) { |
| 23 | 23 | throw new \Exception('12 is the maximum period in xHours feature'); |
| 24 | 24 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function register() |
| 41 | 41 | { |
| 42 | 42 | $this->mergeConfigFrom( |
| 43 | - __DIR__.'/config/visits.php', |
|
| 43 | + __DIR__ . '/config/visits.php', |
|
| 44 | 44 | 'visits' |
| 45 | 45 | ); |
| 46 | 46 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function by($subject) |
| 93 | 93 | { |
| 94 | - if($subject instanceof Model) { |
|
| 94 | + if ($subject instanceof Model) { |
|
| 95 | 95 | $this->keys->append($this->keys->modelName($subject), $subject->{$subject->getKeyName()}); |
| 96 | 96 | } else if (is_array($subject)) { |
| 97 | 97 | $this->keys->append(array_keys($subject)[0], Arr::first($subject)); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function recordedIp() |
| 122 | 122 | { |
| 123 | - return ! $this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX'); |
|
| 123 | + return !$this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -143,8 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | return intval( |
| 145 | 145 | $this->keys->instanceOfModel ? |
| 146 | - $this->redis->zscore($this->keys->visits, $this->keys->id) : |
|
| 147 | - $this->redis->get($this->keys->visitsTotal()) |
|
| 146 | + $this->redis->zscore($this->keys->visits, $this->keys->id) : $this->redis->get($this->keys->visitsTotal()) |
|
| 148 | 147 | ); |
| 149 | 148 | } |
| 150 | 149 | |
@@ -185,14 +184,14 @@ discard block |
||
| 185 | 184 | $this->redis->zincrby($this->keys->visits, $inc, $this->keys->id); |
| 186 | 185 | $this->redis->incrby($this->keys->visitsTotal(), $inc); |
| 187 | 186 | |
| 188 | - if(is_array($this->globalIgnore) && sizeof($this->globalIgnore) > 0) { |
|
| 187 | + if (is_array($this->globalIgnore) && sizeof($this->globalIgnore) > 0) { |
|
| 189 | 188 | $ignore = array_merge($ignore, $this->globalIgnore); |
| 190 | 189 | } |
| 191 | 190 | |
| 192 | 191 | //NOTE: $$method is parameter also .. ($periods,$country,$refer) |
| 193 | 192 | foreach (['country', 'refer', 'periods', 'operatingSystem', 'language'] as $method) { |
| 194 | - if(! in_array($method, $ignore)) { |
|
| 195 | - $this->{'record'.studly_case($method)}($inc); |
|
| 193 | + if (!in_array($method, $ignore)) { |
|
| 194 | + $this->{'record' . studly_case($method)}($inc); |
|
| 196 | 195 | } |
| 197 | 196 | } |
| 198 | 197 | } |