@@ -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 | |
@@ -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 | |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | $class = get_called_class(); |
| 34 | 34 | $instance = new $class; |
| 35 | 35 | |
| 36 | - static::created(function () use ($instance) { |
|
| 36 | + static::created(function() use ($instance) { |
|
| 37 | 37 | $instance->flushCache(); |
| 38 | 38 | }); |
| 39 | 39 | |
| 40 | - static::deleted(function () use ($instance) { |
|
| 40 | + static::deleted(function() use ($instance) { |
|
| 41 | 41 | $instance->flushCache(); |
| 42 | 42 | }); |
| 43 | 43 | |
| 44 | - static::saved(function () use ($instance) { |
|
| 44 | + static::saved(function() use ($instance) { |
|
| 45 | 45 | $instance->flushCache(); |
| 46 | 46 | }); |
| 47 | 47 | |
| 48 | - static::updated(function () use ($instance) { |
|
| 48 | + static::updated(function() use ($instance) { |
|
| 49 | 49 | $instance->flushCache(); |
| 50 | 50 | }); |
| 51 | 51 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $key = $instance->makeCacheKey(); |
| 59 | 59 | |
| 60 | 60 | return $instance->cache($tags) |
| 61 | - ->rememberForever($key, function () use ($columns) { |
|
| 61 | + ->rememberForever($key, function() use ($columns) { |
|
| 62 | 62 | return parent::all($columns); |
| 63 | 63 | }); |
| 64 | 64 | } |
@@ -12,14 +12,14 @@ 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 | 20 | ->rememberForever( |
| 21 | 21 | $this->makeCacheKey(['*'], null, "-avg_{$column}"), |
| 22 | - function () use ($column) { |
|
| 22 | + function() use ($column) { |
|
| 23 | 23 | return parent::avg($column); |
| 24 | 24 | } |
| 25 | 25 | ); |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function count($columns = ['*']) |
| 29 | 29 | { |
| 30 | - if (! $this->isCachable) { |
|
| 30 | + if (!$this->isCachable) { |
|
| 31 | 31 | return parent::count($columns); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | return $this->cache($this->makeCacheTags()) |
| 35 | 35 | ->rememberForever( |
| 36 | 36 | $this->makeCacheKey(['*'], null, "-count"), |
| 37 | - function () use ($columns) { |
|
| 37 | + function() use ($columns) { |
|
| 38 | 38 | return parent::count($columns); |
| 39 | 39 | } |
| 40 | 40 | ); |
@@ -42,14 +42,14 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function cursor() |
| 44 | 44 | { |
| 45 | - if (! $this->isCachable) { |
|
| 45 | + if (!$this->isCachable) { |
|
| 46 | 46 | return collect(parent::cursor()); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | return $this->cache($this->makeCacheTags()) |
| 50 | 50 | ->rememberForever( |
| 51 | 51 | $this->makeCacheKey(['*'], null, "-cursor"), |
| 52 | - function () { |
|
| 52 | + function() { |
|
| 53 | 53 | return collect(parent::cursor()); |
| 54 | 54 | } |
| 55 | 55 | ); |
@@ -68,14 +68,14 @@ 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 | 76 | ->rememberForever( |
| 77 | 77 | $this->makeCacheKey($columns, $id), |
| 78 | - function () use ($id, $columns) { |
|
| 78 | + function() use ($id, $columns) { |
|
| 79 | 79 | return parent::find($id, $columns); |
| 80 | 80 | } |
| 81 | 81 | ); |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | public function first($columns = ['*']) |
| 85 | 85 | { |
| 86 | - if (! $this->isCachable) { |
|
| 86 | + if (!$this->isCachable) { |
|
| 87 | 87 | return parent::first($columns); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | return $this->cache($this->makeCacheTags()) |
| 91 | 91 | ->rememberForever( |
| 92 | 92 | $this->makeCacheKey($columns, null, '-first'), |
| 93 | - function () use ($columns) { |
|
| 93 | + function() use ($columns) { |
|
| 94 | 94 | return parent::first($columns); |
| 95 | 95 | } |
| 96 | 96 | ); |
@@ -98,14 +98,14 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | public function get($columns = ['*']) |
| 100 | 100 | { |
| 101 | - if (! $this->isCachable) { |
|
| 101 | + if (!$this->isCachable) { |
|
| 102 | 102 | return parent::get($columns); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | return $this->cache($this->makeCacheTags()) |
| 106 | 106 | ->rememberForever( |
| 107 | 107 | $this->makeCacheKey($columns), |
| 108 | - function () use ($columns) { |
|
| 108 | + function() use ($columns) { |
|
| 109 | 109 | return parent::get($columns); |
| 110 | 110 | } |
| 111 | 111 | ); |
@@ -113,14 +113,14 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | public function max($column) |
| 115 | 115 | { |
| 116 | - if (! $this->isCachable) { |
|
| 116 | + if (!$this->isCachable) { |
|
| 117 | 117 | return parent::max($column); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $this->cache($this->makeCacheTags()) |
| 121 | 121 | ->rememberForever( |
| 122 | 122 | $this->makeCacheKey(['*'], null, "-max_{$column}"), |
| 123 | - function () use ($column) { |
|
| 123 | + function() use ($column) { |
|
| 124 | 124 | return parent::max($column); |
| 125 | 125 | } |
| 126 | 126 | ); |
@@ -128,14 +128,14 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | public function min($column) |
| 130 | 130 | { |
| 131 | - if (! $this->isCachable) { |
|
| 131 | + if (!$this->isCachable) { |
|
| 132 | 132 | return parent::min($column); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | return $this->cache($this->makeCacheTags()) |
| 136 | 136 | ->rememberForever( |
| 137 | 137 | $this->makeCacheKey(['*'], null, "-min_{$column}"), |
| 138 | - function () use ($column) { |
|
| 138 | + function() use ($column) { |
|
| 139 | 139 | return parent::min($column); |
| 140 | 140 | } |
| 141 | 141 | ); |
@@ -143,29 +143,29 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | public function pluck($column, $key = null) |
| 145 | 145 | { |
| 146 | - if (! $this->isCachable) { |
|
| 146 | + if (!$this->isCachable) { |
|
| 147 | 147 | return parent::pluck($column, $key); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : ""); |
|
| 150 | + $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : ""); |
|
| 151 | 151 | $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator); |
| 152 | 152 | |
| 153 | 153 | return $this->cache($this->makeCacheTags()) |
| 154 | - ->rememberForever($cacheKey, function () use ($column, $key) { |
|
| 154 | + ->rememberForever($cacheKey, function() use ($column, $key) { |
|
| 155 | 155 | return parent::pluck($column, $key); |
| 156 | 156 | }); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | public function sum($column) |
| 160 | 160 | { |
| 161 | - if (! $this->isCachable) { |
|
| 161 | + if (!$this->isCachable) { |
|
| 162 | 162 | return parent::sum($column); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | return $this->cache($this->makeCacheTags()) |
| 166 | 166 | ->rememberForever( |
| 167 | 167 | $this->makeCacheKey(['*'], null, "-sum_{$column}"), |
| 168 | - function () use ($column) { |
|
| 168 | + function() use ($column) { |
|
| 169 | 169 | return parent::sum($column); |
| 170 | 170 | } |
| 171 | 171 | ); |
@@ -173,14 +173,14 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | public function value($column) |
| 175 | 175 | { |
| 176 | - if (! $this->isCachable) { |
|
| 176 | + if (!$this->isCachable) { |
|
| 177 | 177 | return parent::value($column); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | return $this->cache($this->makeCacheTags()) |
| 181 | 181 | ->rememberForever( |
| 182 | 182 | $this->makeCacheKey(['*'], null, "-value_{$column}"), |
| 183 | - function () use ($column) { |
|
| 183 | + function() use ($column) { |
|
| 184 | 184 | return parent::value($column); |
| 185 | 185 | } |
| 186 | 186 | ); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | protected function getLimitClause() : string |
| 45 | 45 | { |
| 46 | - if (! $this->query->limit) { |
|
| 46 | + if (!$this->query->limit) { |
|
| 47 | 47 | return ''; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | protected function getOffsetClause() : string |
| 59 | 59 | { |
| 60 | - if (! $this->query->offset) { |
|
| 60 | + if (!$this->query->offset) { |
|
| 61 | 61 | return ''; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | $orders = collect($this->query->orders); |
| 70 | 70 | |
| 71 | 71 | return $orders |
| 72 | - ->reduce(function ($carry, $order) { |
|
| 72 | + ->reduce(function($carry, $order) { |
|
| 73 | 73 | if (($order['type'] ?? '') === 'Raw') { |
| 74 | - return $carry . '_orderByRaw_' . str_slug($order['sql']); |
|
| 74 | + return $carry.'_orderByRaw_'.str_slug($order['sql']); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - return $carry . '_orderBy_' . $order['column'] . '_' . $order['direction']; |
|
| 77 | + return $carry.'_orderBy_'.$order['column'].'_'.$order['direction']; |
|
| 78 | 78 | }) |
| 79 | 79 | ?: ''; |
| 80 | 80 | } |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | return ''; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - return '_' . implode('_', $columns); |
|
| 88 | + return '_'.implode('_', $columns); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | protected function getTypeClause($where) : string |
| 92 | 92 | { |
| 93 | - $type =in_array($where['type'], ['In', 'Null', 'NotNull', 'between']) |
|
| 93 | + $type = in_array($where['type'], ['In', 'Null', 'NotNull', 'between']) |
|
| 94 | 94 | ? strtolower($where['type']) |
| 95 | 95 | : strtolower($where['operator']); |
| 96 | 96 | |
@@ -107,17 +107,17 @@ discard block |
||
| 107 | 107 | ? implode('_', $where['values']) |
| 108 | 108 | : ''; |
| 109 | 109 | |
| 110 | - if (! $values && $this->query->bindings['where'] ?? false) { |
|
| 110 | + if (!$values && $this->query->bindings['where'] ?? false) { |
|
| 111 | 111 | $values = implode('_', $this->query->bindings['where']); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - return '_' . $values; |
|
| 114 | + return '_'.$values; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | protected function getWhereClauses(array $wheres = []) : string |
| 118 | 118 | { |
| 119 | 119 | return $this->getWheres($wheres) |
| 120 | - ->reduce(function ($carry, $where) { |
|
| 120 | + ->reduce(function($carry, $where) { |
|
| 121 | 121 | $value = $this->getNestedClauses($where); |
| 122 | 122 | $value .= $this->getColumnClauses($where); |
| 123 | 123 | $value .= $this->getRawClauses($where); |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | protected function getNestedClauses(array $where) : string |
| 132 | 132 | { |
| 133 | - if (! in_array($where['type'], ['Exists', 'Nested', 'NotExists'])) { |
|
| 133 | + if (!in_array($where['type'], ['Exists', 'Nested', 'NotExists'])) { |
|
| 134 | 134 | return ''; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - return '_' . strtolower($where['type']) . $this->getWhereClauses($where['query']->wheres); |
|
| 137 | + return '_'.strtolower($where['type']).$this->getWhereClauses($where['query']->wheres); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | protected function getColumnClauses(array $where) : string |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | return ''; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - return "_{$where['boolean']}_" . str_slug($where['sql']); |
|
| 155 | + return "_{$where['boolean']}_".str_slug($where['sql']); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | protected function getOtherClauses(array $where, string $carry = null) : string |
@@ -186,6 +186,6 @@ discard block |
||
| 186 | 186 | return ''; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - return '-' . implode('-', $eagerLoads->keys()->toArray()); |
|
| 189 | + return '-'.implode('-', $eagerLoads->keys()->toArray()); |
|
| 190 | 190 | } |
| 191 | 191 | } |