@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | $class = get_called_class(); |
24 | 24 | $instance = new $class; |
25 | 25 | |
26 | - static::created(function () use ($instance) { |
|
26 | + static::created(function() use ($instance) { |
|
27 | 27 | $instance->flushCache(); |
28 | 28 | }); |
29 | 29 | |
30 | - static::deleted(function () use ($instance) { |
|
30 | + static::deleted(function() use ($instance) { |
|
31 | 31 | $instance->flushCache(); |
32 | 32 | }); |
33 | 33 | |
34 | - static::saved(function () use ($instance) { |
|
34 | + static::saved(function() use ($instance) { |
|
35 | 35 | $instance->flushCache(); |
36 | 36 | }); |
37 | 37 | |
38 | - static::updated(function () use ($instance) { |
|
38 | + static::updated(function() use ($instance) { |
|
39 | 39 | $instance->flushCache(); |
40 | 40 | }); |
41 | 41 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $key = 'genealabslaravelmodelcachingtestsfixturesauthor'; |
66 | 66 | |
67 | 67 | return $instance->cache($tags) |
68 | - ->rememberForever($key, function () use ($columns) { |
|
68 | + ->rememberForever($key, function() use ($columns) { |
|
69 | 69 | return parent::all($columns); |
70 | 70 | }); |
71 | 71 | } |
@@ -8,10 +8,10 @@ |
||
8 | 8 | { |
9 | 9 | return collect($this->eagerLoad) |
10 | 10 | ->keys() |
11 | - ->map(function ($relationName) { |
|
11 | + ->map(function($relationName) { |
|
12 | 12 | $relation = collect(explode('.', $relationName)) |
13 | - ->reduce(function ($carry, $name) { |
|
14 | - if (! $carry) { |
|
13 | + ->reduce(function($carry, $name) { |
|
14 | + if (!$carry) { |
|
15 | 15 | $carry = $this->model; |
16 | 16 | } |
17 | 17 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | protected function getLimitClause() : string |
40 | 40 | { |
41 | - if (! $this->query->limit) { |
|
41 | + if (!$this->query->limit) { |
|
42 | 42 | return ''; |
43 | 43 | } |
44 | 44 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | protected function getOffsetClause() : string |
54 | 54 | { |
55 | - if (! $this->query->offset) { |
|
55 | + if (!$this->query->offset) { |
|
56 | 56 | return ''; |
57 | 57 | } |
58 | 58 | |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | $orders = collect($this->query->orders); |
65 | 65 | |
66 | 66 | return $orders |
67 | - ->reduce(function ($carry, $order) { |
|
67 | + ->reduce(function($carry, $order) { |
|
68 | 68 | if (($order['type'] ?? '') === 'Raw') { |
69 | - return $carry . '_orderByRaw_' . str_slug($order['sql']); |
|
69 | + return $carry.'_orderByRaw_'.str_slug($order['sql']); |
|
70 | 70 | } |
71 | 71 | |
72 | - return $carry . '_orderBy_' . $order['column'] . '_' . $order['direction']; |
|
72 | + return $carry.'_orderBy_'.$order['column'].'_'.$order['direction']; |
|
73 | 73 | }) |
74 | 74 | ?: ''; |
75 | 75 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | return ''; |
81 | 81 | } |
82 | 82 | |
83 | - return '_' . implode('_', $columns); |
|
83 | + return '_'.implode('_', $columns); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | protected function getTypeClause($where) : string |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | protected function getValuesClause(array $where = null) : string |
94 | 94 | { |
95 | 95 | return is_array(array_get($where, 'values')) |
96 | - ? '_' . implode('_', $where['values']) |
|
96 | + ? '_'.implode('_', $where['values']) |
|
97 | 97 | : ''; |
98 | 98 | } |
99 | 99 | |
100 | 100 | protected function getWhereClauses(array $wheres = []) : string |
101 | 101 | { |
102 | 102 | return $this->getWheres($wheres) |
103 | - ->reduce(function ($carry, $where) { |
|
103 | + ->reduce(function($carry, $where) { |
|
104 | 104 | $value = $this->getNestedClauses($where); |
105 | 105 | $value .= $this->getColumnClauses($where); |
106 | 106 | $value .= $this->getRawClauses($where); |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | |
114 | 114 | protected function getNestedClauses(array $where) : string |
115 | 115 | { |
116 | - if (! in_array($where['type'], ['Exists', 'Nested', 'NotExists'])) { |
|
116 | + if (!in_array($where['type'], ['Exists', 'Nested', 'NotExists'])) { |
|
117 | 117 | return ''; |
118 | 118 | } |
119 | 119 | |
120 | - return '_' . strtolower($where['type']) . $this->getWhereClauses($where['query']->wheres); |
|
120 | + return '_'.strtolower($where['type']).$this->getWhereClauses($where['query']->wheres); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | protected function getColumnClauses(array $where) : string |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | return ''; |
136 | 136 | } |
137 | 137 | |
138 | - return "_{$where['boolean']}_" . str_slug($where['sql']); |
|
138 | + return "_{$where['boolean']}_".str_slug($where['sql']); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function getOtherClauses(array $where, string $carry = null) : string |
@@ -170,6 +170,6 @@ discard block |
||
170 | 170 | return ''; |
171 | 171 | } |
172 | 172 | |
173 | - return '-' . implode('-', $eagerLoads->keys()->toArray()); |
|
173 | + return '-'.implode('-', $eagerLoads->keys()->toArray()); |
|
174 | 174 | } |
175 | 175 | } |
@@ -14,36 +14,36 @@ discard block |
||
14 | 14 | |
15 | 15 | public function avg($column) |
16 | 16 | { |
17 | - if (! $this->isCachable) { |
|
17 | + if (!$this->isCachable) { |
|
18 | 18 | return parent::avg($column); |
19 | 19 | } |
20 | 20 | |
21 | 21 | return $this->cache($this->makeCacheTags()) |
22 | - ->rememberForever($this->makeCacheKey() . "-avg_{$column}", function () use ($column) { |
|
22 | + ->rememberForever($this->makeCacheKey()."-avg_{$column}", function() use ($column) { |
|
23 | 23 | return parent::avg($column); |
24 | 24 | }); |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function count($columns = ['*']) |
28 | 28 | { |
29 | - if (! $this->isCachable) { |
|
29 | + if (!$this->isCachable) { |
|
30 | 30 | return parent::count($columns); |
31 | 31 | } |
32 | 32 | |
33 | 33 | return $this->cache($this->makeCacheTags()) |
34 | - ->rememberForever($this->makeCacheKey() . "-count", function () use ($columns) { |
|
34 | + ->rememberForever($this->makeCacheKey()."-count", function() use ($columns) { |
|
35 | 35 | return parent::count($columns); |
36 | 36 | }); |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function cursor() |
40 | 40 | { |
41 | - if (! $this->isCachable) { |
|
41 | + if (!$this->isCachable) { |
|
42 | 42 | return collect(parent::cursor()); |
43 | 43 | } |
44 | 44 | |
45 | 45 | return $this->cache($this->makeCacheTags()) |
46 | - ->rememberForever($this->makeCacheKey() . "-cursor", function () { |
|
46 | + ->rememberForever($this->makeCacheKey()."-cursor", function() { |
|
47 | 47 | return collect(parent::cursor()); |
48 | 48 | }); |
49 | 49 | } |
@@ -68,90 +68,90 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function find($id, $columns = ['*']) |
70 | 70 | { |
71 | - if (! $this->isCachable) { |
|
71 | + if (!$this->isCachable) { |
|
72 | 72 | return parent::find($id, $columns); |
73 | 73 | } |
74 | 74 | |
75 | 75 | return $this->cache($this->makeCacheTags()) |
76 | - ->rememberForever($this->makeCacheKey($columns, $id), function () use ($id, $columns) { |
|
76 | + ->rememberForever($this->makeCacheKey($columns, $id), function() use ($id, $columns) { |
|
77 | 77 | return parent::find($id, $columns); |
78 | 78 | }); |
79 | 79 | } |
80 | 80 | |
81 | 81 | public function first($columns = ['*']) |
82 | 82 | { |
83 | - if (! $this->isCachable) { |
|
83 | + if (!$this->isCachable) { |
|
84 | 84 | return parent::first($columns); |
85 | 85 | } |
86 | 86 | |
87 | 87 | return $this->cache($this->makeCacheTags()) |
88 | - ->rememberForever($this->makeCacheKey($columns) . '-first', function () use ($columns) { |
|
88 | + ->rememberForever($this->makeCacheKey($columns).'-first', function() use ($columns) { |
|
89 | 89 | return parent::first($columns); |
90 | 90 | }); |
91 | 91 | } |
92 | 92 | |
93 | 93 | public function get($columns = ['*']) |
94 | 94 | { |
95 | - if (! $this->isCachable) { |
|
95 | + if (!$this->isCachable) { |
|
96 | 96 | return parent::get($columns); |
97 | 97 | } |
98 | 98 | |
99 | 99 | return $this->cache($this->makeCacheTags()) |
100 | - ->rememberForever($this->makeCacheKey($columns), function () use ($columns) { |
|
100 | + ->rememberForever($this->makeCacheKey($columns), function() use ($columns) { |
|
101 | 101 | return parent::get($columns); |
102 | 102 | }); |
103 | 103 | } |
104 | 104 | |
105 | 105 | public function max($column) |
106 | 106 | { |
107 | - if (! $this->isCachable) { |
|
107 | + if (!$this->isCachable) { |
|
108 | 108 | return parent::max($column); |
109 | 109 | } |
110 | 110 | |
111 | 111 | return $this->cache($this->makeCacheTags()) |
112 | - ->rememberForever($this->makeCacheKey() . "-max_{$column}", function () use ($column) { |
|
112 | + ->rememberForever($this->makeCacheKey()."-max_{$column}", function() use ($column) { |
|
113 | 113 | return parent::max($column); |
114 | 114 | }); |
115 | 115 | } |
116 | 116 | |
117 | 117 | public function min($column) |
118 | 118 | { |
119 | - if (! $this->isCachable) { |
|
119 | + if (!$this->isCachable) { |
|
120 | 120 | return parent::min($column); |
121 | 121 | } |
122 | 122 | |
123 | 123 | return $this->cache($this->makeCacheTags()) |
124 | - ->rememberForever($this->makeCacheKey() . "-min_{$column}", function () use ($column) { |
|
124 | + ->rememberForever($this->makeCacheKey()."-min_{$column}", function() use ($column) { |
|
125 | 125 | return parent::min($column); |
126 | 126 | }); |
127 | 127 | } |
128 | 128 | |
129 | 129 | public function pluck($column, $key = null) |
130 | 130 | { |
131 | - if (! $this->isCachable) { |
|
131 | + if (!$this->isCachable) { |
|
132 | 132 | return parent::pluck($column, $key); |
133 | 133 | } |
134 | 134 | |
135 | - $cacheKey = $this->makeCacheKey([$column]) . "-pluck_{$column}"; |
|
135 | + $cacheKey = $this->makeCacheKey([$column])."-pluck_{$column}"; |
|
136 | 136 | |
137 | 137 | if ($key) { |
138 | 138 | $cacheKey .= "_{$key}"; |
139 | 139 | } |
140 | 140 | |
141 | 141 | return $this->cache($this->makeCacheTags()) |
142 | - ->rememberForever($cacheKey, function () use ($column, $key) { |
|
142 | + ->rememberForever($cacheKey, function() use ($column, $key) { |
|
143 | 143 | return parent::pluck($column, $key); |
144 | 144 | }); |
145 | 145 | } |
146 | 146 | |
147 | 147 | public function sum($column) |
148 | 148 | { |
149 | - if (! $this->isCachable) { |
|
149 | + if (!$this->isCachable) { |
|
150 | 150 | return parent::sum($column); |
151 | 151 | } |
152 | 152 | |
153 | 153 | return $this->cache($this->makeCacheTags()) |
154 | - ->rememberForever($this->makeCacheKey() . "-sum_{$column}", function () use ($column) { |
|
154 | + ->rememberForever($this->makeCacheKey()."-sum_{$column}", function() use ($column) { |
|
155 | 155 | return parent::sum($column); |
156 | 156 | }); |
157 | 157 | } |