@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function visits() |
35 | 35 | { |
36 | - return (app()->environment('testing') ? 'testing:' : '').$this->modelName."_{$this->tag}"; |
|
36 | + return (app()->environment('testing') ? 'testing:' : '') . $this->modelName . "_{$this->tag}"; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function ip($ip) |
51 | 51 | { |
52 | - return $this->visits.'_'.Str::snake( |
|
53 | - 'recorded_ips:'.($this->instanceOfModel ? "{$this->id}:" : '') . $ip |
|
52 | + return $this->visits . '_' . Str::snake( |
|
53 | + 'recorded_ips:' . ($this->instanceOfModel ? "{$this->id}:" : '') . $ip |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function cache($limit = '*', $isLow = false, $constraints = []) |
61 | 61 | { |
62 | - $key = $this->visits.'_lists'; |
|
62 | + $key = $this->visits . '_lists'; |
|
63 | 63 | |
64 | 64 | if ($limit == '*') { |
65 | 65 | return "{$key}:*"; |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | |
68 | 68 | //it might not be that unique but it does the job since not many lists |
69 | 69 | //will be generated to one key.eloquent |
70 | - $constraintsPart = count($constraints) ? ':'.substr(sha1(serialize($constraints)), 0, 7) : ''; |
|
70 | + $constraintsPart = count($constraints) ? ':' . substr(sha1(serialize($constraints)), 0, 7) : ''; |
|
71 | 71 | |
72 | - return "{$key}:".($isLow ? 'low' : 'top').$constraintsPart.$limit; |
|
72 | + return "{$key}:" . ($isLow ? 'low' : 'top') . $constraintsPart . $limit; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function top($limit = 5, $orderByAsc = false, $constraints = []) |
17 | 17 | { |
18 | - if(is_array($orderByAsc)) { |
|
18 | + if (is_array($orderByAsc)) { |
|
19 | 19 | $constraints = $orderByAsc; |
20 | 20 | $orderByAsc = false; |
21 | 21 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $cachedList = $this->cachedList($limit, $cacheKey); |
26 | 26 | $visitsIds = $this->getVisitsIds($limit, $this->keys->visits, $orderByAsc); |
27 | 27 | |
28 | - if($visitsIds === $cachedList->pluck($this->keys->primary)->toArray() && ! $this->fresh) { |
|
28 | + if ($visitsIds === $cachedList->pluck($this->keys->primary)->toArray() && !$this->fresh) { |
|
29 | 29 | return $cachedList; |
30 | 30 | } |
31 | 31 | |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | return $query->where($constraints); |
114 | 114 | }) |
115 | 115 | ->get() |
116 | - ->sortBy(function ($subject) use ($visitsIds) { |
|
116 | + ->sortBy(function($subject) use ($visitsIds) { |
|
117 | 117 | return array_search($subject->{$this->keys->primary}, $visitsIds); |
118 | - })->each(function ($subject) use ($cacheKey) { |
|
118 | + })->each(function($subject) use ($cacheKey) { |
|
119 | 119 | $this->connection->addToFlatList($cacheKey, serialize($subject)); |
120 | 120 | }); |
121 | 121 | } |