@@ -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 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | public function boot() |
11 | 11 | { |
12 | - $configPath = __DIR__ . '/../../config/laravel-model-caching.php'; |
|
12 | + $configPath = __DIR__.'/../../config/laravel-model-caching.php'; |
|
13 | 13 | $this->mergeConfigFrom($configPath, 'laravel-model-caching'); |
14 | 14 | $this->commands(Flush::class); |
15 | 15 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | { |
13 | 13 | $option = $this->option('model'); |
14 | 14 | |
15 | - if (! $option) { |
|
15 | + if (!$option) { |
|
16 | 16 | $this->error("You must specify a model to flush a model's cache:"); |
17 | 17 | $this->line("modelCache:flush --model=App\\Model"); |
18 | 18 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | $model = new $option; |
23 | 23 | |
24 | - if (! $model instanceof CachedModel) { |
|
24 | + if (!$model instanceof CachedModel) { |
|
25 | 25 | $this->error("'{$option}' is not an instance of CachedModel."); |
26 | 26 | $this->line("Only CachedModel instances can be flushed."); |
27 | 27 |
@@ -12,36 +12,36 @@ discard block |
||
12 | 12 | |
13 | 13 | public function avg($column) |
14 | 14 | { |
15 | - if (! $this->isCachable) { |
|
15 | + if (!$this->isCachable) { |
|
16 | 16 | return parent::avg($column); |
17 | 17 | } |
18 | 18 | |
19 | 19 | return $this->cache($this->makeCacheTags()) |
20 | - ->rememberForever($this->makeCacheKey() . "-avg_{$column}", function () use ($column) { |
|
20 | + ->rememberForever($this->makeCacheKey()."-avg_{$column}", function() use ($column) { |
|
21 | 21 | return parent::avg($column); |
22 | 22 | }); |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function count($columns = ['*']) |
26 | 26 | { |
27 | - if (! $this->isCachable) { |
|
27 | + if (!$this->isCachable) { |
|
28 | 28 | return parent::count($columns); |
29 | 29 | } |
30 | 30 | |
31 | 31 | return $this->cache($this->makeCacheTags()) |
32 | - ->rememberForever($this->makeCacheKey() . "-count", function () use ($columns) { |
|
32 | + ->rememberForever($this->makeCacheKey()."-count", function() use ($columns) { |
|
33 | 33 | return parent::count($columns); |
34 | 34 | }); |
35 | 35 | } |
36 | 36 | |
37 | 37 | public function cursor() |
38 | 38 | { |
39 | - if (! $this->isCachable) { |
|
39 | + if (!$this->isCachable) { |
|
40 | 40 | return collect(parent::cursor()); |
41 | 41 | } |
42 | 42 | |
43 | 43 | return $this->cache($this->makeCacheTags()) |
44 | - ->rememberForever($this->makeCacheKey() . "-cursor", function () { |
|
44 | + ->rememberForever($this->makeCacheKey()."-cursor", function() { |
|
45 | 45 | return collect(parent::cursor()); |
46 | 46 | }); |
47 | 47 | } |
@@ -59,102 +59,102 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function find($id, $columns = ['*']) |
61 | 61 | { |
62 | - if (! $this->isCachable) { |
|
62 | + if (!$this->isCachable) { |
|
63 | 63 | return parent::find($id, $columns); |
64 | 64 | } |
65 | 65 | |
66 | 66 | return $this->cache($this->makeCacheTags()) |
67 | - ->rememberForever($this->makeCacheKey($columns, $id), function () use ($id, $columns) { |
|
67 | + ->rememberForever($this->makeCacheKey($columns, $id), function() use ($id, $columns) { |
|
68 | 68 | return parent::find($id, $columns); |
69 | 69 | }); |
70 | 70 | } |
71 | 71 | |
72 | 72 | public function first($columns = ['*']) |
73 | 73 | { |
74 | - if (! $this->isCachable) { |
|
74 | + if (!$this->isCachable) { |
|
75 | 75 | return parent::first($columns); |
76 | 76 | } |
77 | 77 | |
78 | 78 | return $this->cache($this->makeCacheTags()) |
79 | - ->rememberForever($this->makeCacheKey($columns) . '-first', function () use ($columns) { |
|
79 | + ->rememberForever($this->makeCacheKey($columns).'-first', function() use ($columns) { |
|
80 | 80 | return parent::first($columns); |
81 | 81 | }); |
82 | 82 | } |
83 | 83 | |
84 | 84 | public function get($columns = ['*']) |
85 | 85 | { |
86 | - if (! $this->isCachable) { |
|
86 | + if (!$this->isCachable) { |
|
87 | 87 | return parent::get($columns); |
88 | 88 | } |
89 | 89 | |
90 | 90 | return $this->cache($this->makeCacheTags()) |
91 | - ->rememberForever($this->makeCacheKey($columns), function () use ($columns) { |
|
91 | + ->rememberForever($this->makeCacheKey($columns), function() use ($columns) { |
|
92 | 92 | return parent::get($columns); |
93 | 93 | }); |
94 | 94 | } |
95 | 95 | |
96 | 96 | public function max($column) |
97 | 97 | { |
98 | - if (! $this->isCachable) { |
|
98 | + if (!$this->isCachable) { |
|
99 | 99 | return parent::max($column); |
100 | 100 | } |
101 | 101 | |
102 | 102 | return $this->cache($this->makeCacheTags()) |
103 | - ->rememberForever($this->makeCacheKey() . "-max_{$column}", function () use ($column) { |
|
103 | + ->rememberForever($this->makeCacheKey()."-max_{$column}", function() use ($column) { |
|
104 | 104 | return parent::max($column); |
105 | 105 | }); |
106 | 106 | } |
107 | 107 | |
108 | 108 | public function min($column) |
109 | 109 | { |
110 | - if (! $this->isCachable) { |
|
110 | + if (!$this->isCachable) { |
|
111 | 111 | return parent::min($column); |
112 | 112 | } |
113 | 113 | |
114 | 114 | return $this->cache($this->makeCacheTags()) |
115 | - ->rememberForever($this->makeCacheKey() . "-min_{$column}", function () use ($column) { |
|
115 | + ->rememberForever($this->makeCacheKey()."-min_{$column}", function() use ($column) { |
|
116 | 116 | return parent::min($column); |
117 | 117 | }); |
118 | 118 | } |
119 | 119 | |
120 | 120 | public function pluck($column, $key = null) |
121 | 121 | { |
122 | - if (! $this->isCachable) { |
|
122 | + if (!$this->isCachable) { |
|
123 | 123 | return parent::pluck($column, $key); |
124 | 124 | } |
125 | 125 | |
126 | - $cacheKey = $this->makeCacheKey([$column]) . "-pluck_{$column}"; |
|
126 | + $cacheKey = $this->makeCacheKey([$column])."-pluck_{$column}"; |
|
127 | 127 | |
128 | 128 | if ($key) { |
129 | 129 | $cacheKey .= "_{$key}"; |
130 | 130 | } |
131 | 131 | |
132 | 132 | return $this->cache($this->makeCacheTags()) |
133 | - ->rememberForever($cacheKey, function () use ($column, $key) { |
|
133 | + ->rememberForever($cacheKey, function() use ($column, $key) { |
|
134 | 134 | return parent::pluck($column, $key); |
135 | 135 | }); |
136 | 136 | } |
137 | 137 | |
138 | 138 | public function sum($column) |
139 | 139 | { |
140 | - if (! $this->isCachable) { |
|
140 | + if (!$this->isCachable) { |
|
141 | 141 | return parent::sum($column); |
142 | 142 | } |
143 | 143 | |
144 | 144 | return $this->cache($this->makeCacheTags()) |
145 | - ->rememberForever($this->makeCacheKey() . "-sum_{$column}", function () use ($column) { |
|
145 | + ->rememberForever($this->makeCacheKey()."-sum_{$column}", function() use ($column) { |
|
146 | 146 | return parent::sum($column); |
147 | 147 | }); |
148 | 148 | } |
149 | 149 | |
150 | 150 | public function value($column) |
151 | 151 | { |
152 | - if (! $this->isCachable) { |
|
152 | + if (!$this->isCachable) { |
|
153 | 153 | return parent::value($column); |
154 | 154 | } |
155 | 155 | |
156 | 156 | return $this->cache($this->makeCacheTags()) |
157 | - ->rememberForever($this->makeCacheKey() . "-value_{$column}", function () use ($column) { |
|
157 | + ->rememberForever($this->makeCacheKey()."-value_{$column}", function() use ($column) { |
|
158 | 158 | return parent::value($column); |
159 | 159 | }); |
160 | 160 | } |