@@ -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 | } |
@@ -54,23 +54,23 @@ discard block |
||
| 54 | 54 | $key = str_slug(get_class($this->model)); |
| 55 | 55 | |
| 56 | 56 | if ($ids) { |
| 57 | - $key .= '_' . (is_array($ids) |
|
| 57 | + $key .= '_'.(is_array($ids) |
|
| 58 | 58 | ? implode('_', $ids) |
| 59 | 59 | : $ids); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | if ($columns !== ['*']) { |
| 63 | - $key .= '_' . implode('_', $columns); |
|
| 63 | + $key .= '_'.implode('_', $columns); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - $key .= collect($this->query->wheres)->reduce(function ($carry, $where) { |
|
| 66 | + $key .= collect($this->query->wheres)->reduce(function($carry, $where) { |
|
| 67 | 67 | $value = $where['value'] ?? implode('_', $where['values']) ?? ''; |
| 68 | 68 | |
| 69 | 69 | return "{$carry}-{$where['column']}_{$value}"; |
| 70 | 70 | }); |
| 71 | 71 | |
| 72 | 72 | if (collect($this->eagerLoad)->isNotEmpty()) { |
| 73 | - $key .= '-' . implode('-', collect($this->eagerLoad)->keys()->toArray()); |
|
| 73 | + $key .= '-'.implode('-', collect($this->eagerLoad)->keys()->toArray()); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if ($this->query->offset) { |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | protected function getCacheTags() : array |
| 88 | 88 | { |
| 89 | 89 | return collect($this->eagerLoad)->keys() |
| 90 | - ->map(function ($name) { |
|
| 90 | + ->map(function($name) { |
|
| 91 | 91 | return str_slug(get_class( |
| 92 | 92 | $this->model |
| 93 | 93 | ->{$name}() |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | public function avg($column) |
| 104 | 104 | { |
| 105 | 105 | $tags = [str_slug(get_class($this->model))]; |
| 106 | - $key = str_slug(get_class($this->model)) ."-avg_{$column}"; |
|
| 106 | + $key = str_slug(get_class($this->model))."-avg_{$column}"; |
|
| 107 | 107 | |
| 108 | 108 | return $this->cache($tags) |
| 109 | - ->rememberForever($key, function () use ($column) { |
|
| 109 | + ->rememberForever($key, function() use ($column) { |
|
| 110 | 110 | return parent::avg($column); |
| 111 | 111 | }); |
| 112 | 112 | } |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | public function count($columns = ['*']) |
| 115 | 115 | { |
| 116 | 116 | $tags = [str_slug(get_class($this->model))]; |
| 117 | - $key = str_slug(get_class($this->model)) ."-count"; |
|
| 117 | + $key = str_slug(get_class($this->model))."-count"; |
|
| 118 | 118 | |
| 119 | 119 | return $this->cache($tags) |
| 120 | - ->rememberForever($key, function () use ($columns) { |
|
| 120 | + ->rememberForever($key, function() use ($columns) { |
|
| 121 | 121 | return parent::count($columns); |
| 122 | 122 | }); |
| 123 | 123 | } |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | public function cursor() |
| 126 | 126 | { |
| 127 | 127 | $tags = [str_slug(get_class($this->model))]; |
| 128 | - $key = str_slug(get_class($this->model)) ."-cursor"; |
|
| 128 | + $key = str_slug(get_class($this->model))."-cursor"; |
|
| 129 | 129 | |
| 130 | 130 | return $this->cache($tags) |
| 131 | - ->rememberForever($key, function () { |
|
| 131 | + ->rememberForever($key, function() { |
|
| 132 | 132 | return collect(parent::cursor()); |
| 133 | 133 | }); |
| 134 | 134 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $key = $this->getCacheKey($columns, $id); |
| 143 | 143 | |
| 144 | 144 | return $this->cache($tags) |
| 145 | - ->rememberForever($key, function () use ($id, $columns) { |
|
| 145 | + ->rememberForever($key, function() use ($id, $columns) { |
|
| 146 | 146 | return parent::find($id, $columns); |
| 147 | 147 | }); |
| 148 | 148 | } |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | public function first($columns = ['*']) |
| 151 | 151 | { |
| 152 | 152 | $tags = $this->getCacheTags(); |
| 153 | - $key = $this->getCacheKey($columns) . '-first'; |
|
| 153 | + $key = $this->getCacheKey($columns).'-first'; |
|
| 154 | 154 | |
| 155 | 155 | return $this->cache($tags) |
| 156 | - ->rememberForever($key, function () use ($columns) { |
|
| 156 | + ->rememberForever($key, function() use ($columns) { |
|
| 157 | 157 | return parent::first($columns); |
| 158 | 158 | }); |
| 159 | 159 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $key = $this->getCacheKey($columns); |
| 165 | 165 | |
| 166 | 166 | return $this->cache($tags) |
| 167 | - ->rememberForever($key, function () use ($columns) { |
|
| 167 | + ->rememberForever($key, function() use ($columns) { |
|
| 168 | 168 | return parent::get($columns); |
| 169 | 169 | }); |
| 170 | 170 | } |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | public function max($column) |
| 173 | 173 | { |
| 174 | 174 | $tags = [str_slug(get_class($this->model))]; |
| 175 | - $key = str_slug(get_class($this->model)) ."-max_{$column}"; |
|
| 175 | + $key = str_slug(get_class($this->model))."-max_{$column}"; |
|
| 176 | 176 | |
| 177 | 177 | return $this->cache($tags) |
| 178 | - ->rememberForever($key, function () use ($column) { |
|
| 178 | + ->rememberForever($key, function() use ($column) { |
|
| 179 | 179 | return parent::max($column); |
| 180 | 180 | }); |
| 181 | 181 | } |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | public function min($column) |
| 184 | 184 | { |
| 185 | 185 | $tags = [str_slug(get_class($this->model))]; |
| 186 | - $key = str_slug(get_class($this->model)) ."-min_{$column}"; |
|
| 186 | + $key = str_slug(get_class($this->model))."-min_{$column}"; |
|
| 187 | 187 | |
| 188 | 188 | return $this->cache($tags) |
| 189 | - ->rememberForever($key, function () use ($column) { |
|
| 189 | + ->rememberForever($key, function() use ($column) { |
|
| 190 | 190 | return parent::min($column); |
| 191 | 191 | }); |
| 192 | 192 | } |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | public function pluck($column, $key = null) |
| 195 | 195 | { |
| 196 | 196 | $tags = $this->getCacheTags(); |
| 197 | - $cacheKey = $this->getCacheKey([$column]) . "-pluck_{$column}"; |
|
| 197 | + $cacheKey = $this->getCacheKey([$column])."-pluck_{$column}"; |
|
| 198 | 198 | |
| 199 | 199 | if ($key) { |
| 200 | 200 | $cacheKey .= "_{$key}"; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | return $this->cache($tags) |
| 204 | - ->rememberForever($cacheKey, function () use ($column, $key) { |
|
| 204 | + ->rememberForever($cacheKey, function() use ($column, $key) { |
|
| 205 | 205 | return parent::pluck($column, $key); |
| 206 | 206 | }); |
| 207 | 207 | } |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | public function sum($column) |
| 210 | 210 | { |
| 211 | 211 | $tags = [str_slug(get_class($this->model))]; |
| 212 | - $key = str_slug(get_class($this->model)) ."-sum_{$column}"; |
|
| 212 | + $key = str_slug(get_class($this->model))."-sum_{$column}"; |
|
| 213 | 213 | |
| 214 | 214 | return $this->cache($tags) |
| 215 | - ->rememberForever($key, function () use ($column) { |
|
| 215 | + ->rememberForever($key, function() use ($column) { |
|
| 216 | 216 | return parent::sum($column); |
| 217 | 217 | }); |
| 218 | 218 | } |
@@ -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 | |