@@ -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 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | factory(Author::class, 10)->create() |
20 | 20 | ->each(function($author) { |
21 | 21 | factory(Book::class, random_int(2, 10))->make() |
22 | - ->each(function ($book) use ($author) { |
|
22 | + ->each(function($book) use ($author) { |
|
23 | 23 | $book->author()->associate($author); |
24 | 24 | $book->save(); |
25 | 25 | }); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | $bookIds = (new Book)->all()->pluck('id'); |
32 | 32 | factory(Store::class, 10)->create() |
33 | - ->each(function ($store) use ($bookIds) { |
|
33 | + ->each(function($store) use ($bookIds) { |
|
34 | 34 | $store->books()->sync(rand($bookIds->min(), $bookIds->max())); |
35 | 35 | }); |
36 | 36 | cache()->flush(); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | factory(Author::class, 10)->create() |
24 | 24 | ->each(function($author) { |
25 | 25 | factory(Book::class, random_int(2, 10))->make() |
26 | - ->each(function ($book) use ($author) { |
|
26 | + ->each(function($book) use ($author) { |
|
27 | 27 | $book->author()->associate($author); |
28 | 28 | $book->save(); |
29 | 29 | }); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | $bookIds = (new Book)->all()->pluck('id'); |
36 | 36 | factory(Store::class, 10)->create() |
37 | - ->each(function ($store) use ($bookIds) { |
|
37 | + ->each(function($store) use ($bookIds) { |
|
38 | 38 | $store->books()->sync(rand($bookIds->min(), $bookIds->max())); |
39 | 39 | }); |
40 | 40 | cache()->flush(); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $uncachedChunks = collect(); |
213 | 213 | |
214 | 214 | (new Author)->with('books', 'profile') |
215 | - ->chunk($chunkSize, function ($chunk) use (&$cachedChunks, $chunkSize) { |
|
215 | + ->chunk($chunkSize, function($chunk) use (&$cachedChunks, $chunkSize) { |
|
216 | 216 | $offset = ''; |
217 | 217 | |
218 | 218 | if ($cachedChunks['authors']->count()) { |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | }); |
226 | 226 | |
227 | 227 | (new UncachedAuthor)->with('books', 'profile') |
228 | - ->chunk($chunkSize, function ($chunk) use (&$uncachedChunks) { |
|
228 | + ->chunk($chunkSize, function($chunk) use (&$uncachedChunks) { |
|
229 | 229 | $uncachedChunks->push($chunk); |
230 | 230 | }); |
231 | 231 |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | $key .= $idColumn ? "_{$idColumn}" : ''; |
27 | 27 | |
28 | 28 | if ($columns !== ['*']) { |
29 | - $key .= '_' . implode('_', $columns); |
|
29 | + $key .= '_'.implode('_', $columns); |
|
30 | 30 | } |
31 | 31 | |
32 | - $key .= collect($this->query->wheres)->reduce(function ($carry, $where) { |
|
32 | + $key .= collect($this->query->wheres)->reduce(function($carry, $where) { |
|
33 | 33 | $value = $where['value'] ?? implode('_', $where['values']) ?? ''; |
34 | 34 | |
35 | 35 | return "{$carry}-{$where['column']}_{$value}"; |
36 | 36 | }); |
37 | 37 | |
38 | 38 | if (collect($this->eagerLoad)->isNotEmpty()) { |
39 | - $key .= '-' . implode('-', collect($this->eagerLoad)->keys()->toArray()); |
|
39 | + $key .= '-'.implode('-', collect($this->eagerLoad)->keys()->toArray()); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | if ($this->query->offset) { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | protected function getCacheTags() : array |
54 | 54 | { |
55 | 55 | return collect($this->eagerLoad)->keys() |
56 | - ->map(function ($name) { |
|
56 | + ->map(function($name) { |
|
57 | 57 | return str_slug(get_class( |
58 | 58 | $this->model |
59 | 59 | ->{$name}() |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | public function avg($column) |
70 | 70 | { |
71 | 71 | $tags = [str_slug(get_class($this->model))]; |
72 | - $key = str_slug(get_class($this->model)) ."-avg_{$column}"; |
|
72 | + $key = str_slug(get_class($this->model))."-avg_{$column}"; |
|
73 | 73 | |
74 | 74 | return $this->cache($tags) |
75 | - ->rememberForever($key, function () use ($column) { |
|
75 | + ->rememberForever($key, function() use ($column) { |
|
76 | 76 | return parent::avg($column); |
77 | 77 | }); |
78 | 78 | } |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | public function count($columns = ['*']) |
81 | 81 | { |
82 | 82 | $tags = [str_slug(get_class($this->model))]; |
83 | - $key = str_slug(get_class($this->model)) ."-count"; |
|
83 | + $key = str_slug(get_class($this->model))."-count"; |
|
84 | 84 | |
85 | 85 | return $this->cache($tags) |
86 | - ->rememberForever($key, function () use ($columns) { |
|
86 | + ->rememberForever($key, function() use ($columns) { |
|
87 | 87 | return parent::count($columns); |
88 | 88 | }); |
89 | 89 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | public function cursor() |
92 | 92 | { |
93 | 93 | $tags = [str_slug(get_class($this->model))]; |
94 | - $key = str_slug(get_class($this->model)) ."-cursor"; |
|
94 | + $key = str_slug(get_class($this->model))."-cursor"; |
|
95 | 95 | |
96 | 96 | return $this->cache($tags) |
97 | - ->rememberForever($key, function () { |
|
97 | + ->rememberForever($key, function() { |
|
98 | 98 | return collect(parent::cursor()); |
99 | 99 | }); |
100 | 100 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $key = $this->getCacheKey($columns, $id); |
109 | 109 | |
110 | 110 | return $this->cache($tags) |
111 | - ->rememberForever($key, function () use ($id, $columns) { |
|
111 | + ->rememberForever($key, function() use ($id, $columns) { |
|
112 | 112 | return parent::find($id, $columns); |
113 | 113 | }); |
114 | 114 | } |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | public function first($columns = ['*']) |
117 | 117 | { |
118 | 118 | $tags = $this->getCacheTags(); |
119 | - $key = $this->getCacheKey($columns) . '-first'; |
|
119 | + $key = $this->getCacheKey($columns).'-first'; |
|
120 | 120 | |
121 | 121 | return $this->cache($tags) |
122 | - ->rememberForever($key, function () use ($columns) { |
|
122 | + ->rememberForever($key, function() use ($columns) { |
|
123 | 123 | return parent::first($columns); |
124 | 124 | }); |
125 | 125 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $key = $this->getCacheKey($columns); |
131 | 131 | |
132 | 132 | return $this->cache($tags) |
133 | - ->rememberForever($key, function () use ($columns) { |
|
133 | + ->rememberForever($key, function() use ($columns) { |
|
134 | 134 | return parent::get($columns); |
135 | 135 | }); |
136 | 136 | } |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | public function max($column) |
139 | 139 | { |
140 | 140 | $tags = [str_slug(get_class($this->model))]; |
141 | - $key = str_slug(get_class($this->model)) ."-max_{$column}"; |
|
141 | + $key = str_slug(get_class($this->model))."-max_{$column}"; |
|
142 | 142 | |
143 | 143 | return $this->cache($tags) |
144 | - ->rememberForever($key, function () use ($column) { |
|
144 | + ->rememberForever($key, function() use ($column) { |
|
145 | 145 | return parent::max($column); |
146 | 146 | }); |
147 | 147 | } |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | public function min($column) |
150 | 150 | { |
151 | 151 | $tags = [str_slug(get_class($this->model))]; |
152 | - $key = str_slug(get_class($this->model)) ."-min_{$column}"; |
|
152 | + $key = str_slug(get_class($this->model))."-min_{$column}"; |
|
153 | 153 | |
154 | 154 | return $this->cache($tags) |
155 | - ->rememberForever($key, function () use ($column) { |
|
155 | + ->rememberForever($key, function() use ($column) { |
|
156 | 156 | return parent::min($column); |
157 | 157 | }); |
158 | 158 | } |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | public function pluck($column, $key = null) |
161 | 161 | { |
162 | 162 | $tags = $this->getCacheTags(); |
163 | - $cacheKey = $this->getCacheKey([$column]) . "-pluck_{$column}"; |
|
163 | + $cacheKey = $this->getCacheKey([$column])."-pluck_{$column}"; |
|
164 | 164 | |
165 | 165 | if ($key) { |
166 | 166 | $cacheKey .= "_{$key}"; |
167 | 167 | } |
168 | 168 | |
169 | 169 | return $this->cache($tags) |
170 | - ->rememberForever($cacheKey, function () use ($column, $key) { |
|
170 | + ->rememberForever($cacheKey, function() use ($column, $key) { |
|
171 | 171 | return parent::pluck($column, $key); |
172 | 172 | }); |
173 | 173 | } |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | public function sum($column) |
176 | 176 | { |
177 | 177 | $tags = [str_slug(get_class($this->model))]; |
178 | - $key = str_slug(get_class($this->model)) ."-sum_{$column}"; |
|
178 | + $key = str_slug(get_class($this->model))."-sum_{$column}"; |
|
179 | 179 | |
180 | 180 | return $this->cache($tags) |
181 | - ->rememberForever($key, function () use ($column) { |
|
181 | + ->rememberForever($key, function() use ($column) { |
|
182 | 182 | return parent::sum($column); |
183 | 183 | }); |
184 | 184 | } |