@@ -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 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $usesCachableTrait = collect(class_uses($this)) |
| 34 | 34 | ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable"); |
| 35 | 35 | |
| 36 | - if (! $usesCachableTrait) { |
|
| 36 | + if (!$usesCachableTrait) { |
|
| 37 | 37 | array_push($tags, str_slug(get_called_class())); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public static function bootCachable() |
| 81 | 81 | { |
| 82 | - static::saved(function ($instance) { |
|
| 82 | + static::saved(function($instance) { |
|
| 83 | 83 | $instance->flushCache(); |
| 84 | 84 | }); |
| 85 | 85 | } |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | $key = $instance->makeCacheKey(); |
| 93 | 93 | |
| 94 | 94 | return $instance->cache($tags) |
| 95 | - ->rememberForever($key, function () use ($columns) { |
|
| 95 | + ->rememberForever($key, function() use ($columns) { |
|
| 96 | 96 | return parent::all($columns); |
| 97 | 97 | }); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | public function newEloquentBuilder($query) |
| 101 | 101 | { |
| 102 | - if (! $this->isCachable) { |
|
| 102 | + if (!$this->isCachable) { |
|
| 103 | 103 | $this->isCachable = true; |
| 104 | 104 | |
| 105 | 105 | return new EloquentBuilder($query); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | $option = $this->option('model'); |
| 13 | 13 | |
| 14 | - if (! $option) { |
|
| 14 | + if (!$option) { |
|
| 15 | 15 | cache() |
| 16 | 16 | ->store(config('laravel-model-caching.store')) |
| 17 | 17 | ->flush(); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | $usesCachableTrait = collect(class_uses($model)) |
| 26 | 26 | ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable"); |
| 27 | 27 | |
| 28 | - if (! $usesCachableTrait) { |
|
| 28 | + if (!$usesCachableTrait) { |
|
| 29 | 29 | $this->error("'{$option}' is not an instance of CachedModel."); |
| 30 | 30 | $this->line("Only CachedModel instances can be flushed."); |
| 31 | 31 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | { |
| 15 | 15 | return "genealabs:laravel-model-caching:" |
| 16 | 16 | . (config('laravel-model-caching.cache-prefix') |
| 17 | - ? config('laravel-model-caching.cache-prefix', '') . ":" |
|
| 17 | + ? config('laravel-model-caching.cache-prefix', '').":" |
|
| 18 | 18 | : ""); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | protected function getLimitClause() : string |
| 56 | 56 | { |
| 57 | - if (! $this->query->limit) { |
|
| 57 | + if (!$this->query->limit) { |
|
| 58 | 58 | return ''; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | protected function getOffsetClause() : string |
| 70 | 70 | { |
| 71 | - if (! $this->query->offset) { |
|
| 71 | + if (!$this->query->offset) { |
|
| 72 | 72 | return ''; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | $orders = collect($this->query->orders); |
| 81 | 81 | |
| 82 | 82 | return $orders |
| 83 | - ->reduce(function ($carry, $order) { |
|
| 83 | + ->reduce(function($carry, $order) { |
|
| 84 | 84 | if (($order['type'] ?? '') === 'Raw') { |
| 85 | - return $carry . '_orderByRaw_' . str_slug($order['sql']); |
|
| 85 | + return $carry.'_orderByRaw_'.str_slug($order['sql']); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - return $carry . '_orderBy_' . $order['column'] . '_' . $order['direction']; |
|
| 88 | + return $carry.'_orderBy_'.$order['column'].'_'.$order['direction']; |
|
| 89 | 89 | }) |
| 90 | 90 | ?: ''; |
| 91 | 91 | } |
@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | return ''; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - return '_' . implode('_', $columns); |
|
| 99 | + return '_'.implode('_', $columns); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | protected function getTypeClause($where) : string |
| 103 | 103 | { |
| 104 | - $type =in_array($where['type'], ['In', 'NotIn', 'Null', 'NotNull', 'between']) |
|
| 104 | + $type = in_array($where['type'], ['In', 'NotIn', 'Null', 'NotNull', 'between']) |
|
| 105 | 105 | ? strtolower($where['type']) |
| 106 | 106 | : strtolower($where['operator']); |
| 107 | 107 | |
@@ -118,17 +118,17 @@ discard block |
||
| 118 | 118 | ? implode('_', $where['values']) |
| 119 | 119 | : ''; |
| 120 | 120 | |
| 121 | - if (! $values && $this->query->bindings['where'] ?? false) { |
|
| 121 | + if (!$values && $this->query->bindings['where'] ?? false) { |
|
| 122 | 122 | $values = implode('_', $this->query->bindings['where']); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - return '_' . $values; |
|
| 125 | + return '_'.$values; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | protected function getWhereClauses(array $wheres = []) : string |
| 129 | 129 | { |
| 130 | 130 | return $this->getWheres($wheres) |
| 131 | - ->reduce(function ($carry, $where) { |
|
| 131 | + ->reduce(function($carry, $where) { |
|
| 132 | 132 | $value = $this->getNestedClauses($where); |
| 133 | 133 | $value .= $this->getColumnClauses($where); |
| 134 | 134 | $value .= $this->getRawClauses($where); |
@@ -141,11 +141,11 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | protected function getNestedClauses(array $where) : string |
| 143 | 143 | { |
| 144 | - if (! in_array($where['type'], ['Exists', 'Nested', 'NotExists'])) { |
|
| 144 | + if (!in_array($where['type'], ['Exists', 'Nested', 'NotExists'])) { |
|
| 145 | 145 | return ''; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - return '_' . strtolower($where['type']) . $this->getWhereClauses($where['query']->wheres); |
|
| 148 | + return '_'.strtolower($where['type']).$this->getWhereClauses($where['query']->wheres); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | protected function getColumnClauses(array $where) : string |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | return ''; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - return "_{$where['boolean']}_" . str_slug($where['sql']); |
|
| 166 | + return "_{$where['boolean']}_".str_slug($where['sql']); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | protected function getOtherClauses(array $where, string $carry = null) : string |
@@ -197,6 +197,6 @@ discard block |
||
| 197 | 197 | return ''; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - return '-' . implode('-', $eagerLoads->keys()->toArray()); |
|
| 200 | + return '-'.implode('-', $eagerLoads->keys()->toArray()); |
|
| 201 | 201 | } |
| 202 | 202 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | return "genealabs:laravel-model-caching:" |
| 21 | 21 | . (config('laravel-model-caching.cache-prefix') |
| 22 | - ? config('laravel-model-caching.cache-prefix', '') . ":" |
|
| 22 | + ? config('laravel-model-caching.cache-prefix', '').":" |
|
| 23 | 23 | : ""); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | $tags = collect($this->eagerLoad) |
| 29 | 29 | ->keys() |
| 30 | - ->map(function ($relationName) { |
|
| 30 | + ->map(function($relationName) { |
|
| 31 | 31 | $relation = collect(explode('.', $relationName)) |
| 32 | - ->reduce(function ($carry, $name) { |
|
| 33 | - if (! $carry) { |
|
| 32 | + ->reduce(function($carry, $name) { |
|
| 33 | + if (!$carry) { |
|
| 34 | 34 | $carry = $this->model; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -12,7 +12,7 @@ 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 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public function count($columns = ['*']) |
| 27 | 27 | { |
| 28 | - if (! $this->isCachable) { |
|
| 28 | + if (!$this->isCachable) { |
|
| 29 | 29 | return parent::count($columns); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -38,7 +38,7 @@ discard block |
||
| 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 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function find($id, $columns = ['*']) |
| 64 | 64 | { |
| 65 | - if (! $this->isCachable) { |
|
| 65 | + if (!$this->isCachable) { |
|
| 66 | 66 | return parent::find($id, $columns); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | public function first($columns = ['*']) |
| 77 | 77 | { |
| 78 | - if (! $this->isCachable) { |
|
| 78 | + if (!$this->isCachable) { |
|
| 79 | 79 | return parent::first($columns); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | public function get($columns = ['*']) |
| 90 | 90 | { |
| 91 | - if (! $this->isCachable) { |
|
| 91 | + if (!$this->isCachable) { |
|
| 92 | 92 | return parent::get($columns); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | public function max($column) |
| 103 | 103 | { |
| 104 | - if (! $this->isCachable) { |
|
| 104 | + if (!$this->isCachable) { |
|
| 105 | 105 | return parent::max($column); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | public function min($column) |
| 116 | 116 | { |
| 117 | - if (! $this->isCachable) { |
|
| 117 | + if (!$this->isCachable) { |
|
| 118 | 118 | return parent::min($column); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $pageName = 'page', |
| 132 | 132 | $page = null |
| 133 | 133 | ) { |
| 134 | - if (! $this->isCachable) { |
|
| 134 | + if (!$this->isCachable) { |
|
| 135 | 135 | return parent::paginate($perPage, $columns, $pageName, $page); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | public function pluck($column, $key = null) |
| 147 | 147 | { |
| 148 | - if (! $this->isCachable) { |
|
| 148 | + if (!$this->isCachable) { |
|
| 149 | 149 | return parent::pluck($column, $key); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $keyDifferentiator = "-pluck_{$column}" . ($key ? "_{$key}" : ""); |
|
| 152 | + $keyDifferentiator = "-pluck_{$column}".($key ? "_{$key}" : ""); |
|
| 153 | 153 | $arguments = func_get_args(); |
| 154 | 154 | $cacheKey = $this->makeCacheKey([$column], null, $keyDifferentiator); |
| 155 | 155 | $method = 'pluck'; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | public function sum($column) |
| 161 | 161 | { |
| 162 | - if (! $this->isCachable) { |
|
| 162 | + if (!$this->isCachable) { |
|
| 163 | 163 | return parent::sum($column); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | public function value($column) |
| 174 | 174 | { |
| 175 | - if (! $this->isCachable) { |
|
| 175 | + if (!$this->isCachable) { |
|
| 176 | 176 | return parent::value($column); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | return $this->cache($cacheTags) |
| 242 | 242 | ->rememberForever( |
| 243 | 243 | $hashedCacheKey, |
| 244 | - function () use ($arguments, $cacheKey, $method) { |
|
| 244 | + function() use ($arguments, $cacheKey, $method) { |
|
| 245 | 245 | return [ |
| 246 | 246 | 'key' => $cacheKey, |
| 247 | 247 | 'value' => parent::{$method}(...$arguments), |