@@ -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 | } |
@@ -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 | } |
@@ -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 | /** |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | protected function recordRefer($inc) |
21 | 21 | { |
22 | - $this->redis->zincrby($this->keys->visits."_referers:{$this->keys->id}", $inc, $this->getVisitorReferer()); |
|
22 | + $this->redis->zincrby($this->keys->visits . "_referers:{$this->keys->id}", $inc, $this->getVisitorReferer()); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | protected function recordOperatingSystem($inc) |
29 | 29 | { |
30 | - $this->redis->zincrby($this->keys->visits."_OSes:{$this->keys->id}", $inc, $this->getVisitorOperatingSystem()); |
|
30 | + $this->redis->zincrby($this->keys->visits . "_OSes:{$this->keys->id}", $inc, $this->getVisitorOperatingSystem()); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | protected function recordLanguage($inc) |
37 | 37 | { |
38 | - $this->redis->zincrby($this->keys->visits."_languages:{$this->keys->id}", $inc, $this->getVisitorLanguage()); |
|
38 | + $this->redis->zincrby($this->keys->visits . "_languages:{$this->keys->id}", $inc, $this->getVisitorLanguage()); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $periodKey = $this->keys->period($period); |
48 | 48 | |
49 | 49 | $this->redis->zincrby($periodKey, $inc, $this->keys->id); |
50 | - $this->redis->incrby($periodKey.'_total', $inc); |
|
50 | + $this->redis->incrby($periodKey . '_total', $inc); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function by($subject) |
94 | 94 | { |
95 | - if($subject instanceof Model) { |
|
95 | + if ($subject instanceof Model) { |
|
96 | 96 | $this->keys->append($this->keys->modelName($subject), $subject->{$subject->getKeyName()}); |
97 | 97 | } else if (is_array($subject)) { |
98 | 98 | $this->keys->append(array_keys($subject)[0], Arr::first($subject)); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function recordedIp() |
123 | 123 | { |
124 | - return ! $this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX'); |
|
124 | + return !$this->redis->set($this->keys->ip(request()->ip()), true, 'EX', $this->ipSeconds, 'NX'); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -144,8 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | return intval( |
146 | 146 | $this->keys->instanceOfModel ? |
147 | - $this->redis->zscore($this->keys->visits, $this->keys->id) : |
|
148 | - $this->redis->get($this->keys->visitsTotal()) |
|
147 | + $this->redis->zscore($this->keys->visits, $this->keys->id) : $this->redis->get($this->keys->visitsTotal()) |
|
149 | 148 | ); |
150 | 149 | } |
151 | 150 | |
@@ -186,14 +185,14 @@ discard block |
||
186 | 185 | $this->redis->zincrby($this->keys->visits, $inc, $this->keys->id); |
187 | 186 | $this->redis->incrby($this->keys->visitsTotal(), $inc); |
188 | 187 | |
189 | - if(is_array($this->globalIgnore) && sizeof($this->globalIgnore) > 0) { |
|
188 | + if (is_array($this->globalIgnore) && sizeof($this->globalIgnore) > 0) { |
|
190 | 189 | $ignore = array_merge($ignore, $this->globalIgnore); |
191 | 190 | } |
192 | 191 | |
193 | 192 | //NOTE: $$method is parameter also .. ($periods,$country,$refer) |
194 | 193 | foreach (['country', 'refer', 'periods', 'operatingSystem', 'language'] as $method) { |
195 | - if(! in_array($method, $ignore)) { |
|
196 | - $this->{'record'.Str::studly($method)}($inc); |
|
194 | + if (!in_array($method, $ignore)) { |
|
195 | + $this->{'record' . Str::studly($method)}($inc); |
|
197 | 196 | } |
198 | 197 | } |
199 | 198 | } |