@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | protected function applyScopesToInstance() |
49 | 49 | { |
50 | 50 | if ( |
51 | - ! property_exists($this, "scopes") |
|
51 | + !property_exists($this, "scopes") |
|
52 | 52 | || $this->scopesAreApplied |
53 | 53 | || $this->withoutAllGlobalScopes |
54 | 54 | ) { |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | |
58 | 58 | foreach ($this->scopes as $identifier => $scope) { |
59 | 59 | if ( |
60 | - ! isset($this->scopes[$identifier]) |
|
60 | + !isset($this->scopes[$identifier]) |
|
61 | 61 | || isset($this->withoutGlobalScopes[$identifier]) |
62 | 62 | ) { |
63 | 63 | continue; |
64 | 64 | } |
65 | 65 | |
66 | - $this->callScope(function () use ($scope) { |
|
66 | + $this->callScope(function() use ($scope) { |
|
67 | 67 | if ($scope instanceof Closure) { |
68 | 68 | $scope($this); |
69 | 69 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at"; |
123 | 123 | |
124 | 124 | $this->cache() |
125 | - ->rememberForever($cacheKey, function () { |
|
125 | + ->rememberForever($cacheKey, function() { |
|
126 | 126 | return (new Carbon)->now(); |
127 | 127 | }); |
128 | 128 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | public function getModelCacheCooldown(Model $instance) : array |
203 | 203 | { |
204 | - if (! $instance->cacheCooldownSeconds) { |
|
204 | + if (!$instance->cacheCooldownSeconds) { |
|
205 | 205 | return [null, null, null]; |
206 | 206 | } |
207 | 207 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | [$cacheCooldown, $invalidatedAt, $savedAt] = $this |
211 | 211 | ->getCacheCooldownDetails($instance, $cachePrefix, $modelClassName); |
212 | 212 | |
213 | - if (! $cacheCooldown || $cacheCooldown === 0) { |
|
213 | + if (!$cacheCooldown || $cacheCooldown === 0) { |
|
214 | 214 | return [null, null, null]; |
215 | 215 | } |
216 | 216 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance); |
241 | 241 | |
242 | 242 | if ( |
243 | - ! $cacheCooldown |
|
243 | + !$cacheCooldown |
|
244 | 244 | || (new Carbon)->now()->diffInSeconds($invalidatedAt) < $cacheCooldown |
245 | 245 | ) { |
246 | 246 | return; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | { |
266 | 266 | [$cacheCooldown, $invalidatedAt] = $instance->getModelCacheCooldown($instance); |
267 | 267 | |
268 | - if (! $cacheCooldown) { |
|
268 | + if (!$cacheCooldown) { |
|
269 | 269 | $instance->flushCache(); |
270 | 270 | |
271 | 271 | if ($relationship) { |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | public function isCachable() : bool |
294 | 294 | { |
295 | - $isCacheDisabled = ! Container::getInstance() |
|
295 | + $isCacheDisabled = !Container::getInstance() |
|
296 | 296 | ->make("config") |
297 | 297 | ->get("laravel-model-caching.enabled"); |
298 | 298 | $allRelationshipsAreCachable = true; |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | $allRelationshipsAreCachable = collect($this |
305 | 305 | ->eagerLoad) |
306 | 306 | ->keys() |
307 | - ->reduce(function ($carry, $related) { |
|
307 | + ->reduce(function($carry, $related) { |
|
308 | 308 | if ( |
309 | - ! method_exists($this->model, $related) |
|
309 | + !method_exists($this->model, $related) |
|
310 | 310 | || $carry === false |
311 | 311 | ) { |
312 | 312 | return $carry; |
@@ -315,8 +315,8 @@ discard block |
||
315 | 315 | $relatedModel = $this->model->$related()->getRelated(); |
316 | 316 | |
317 | 317 | if ( |
318 | - ! method_exists($relatedModel, "isCachable") |
|
319 | - || ! $relatedModel->isCachable() |
|
318 | + !method_exists($relatedModel, "isCachable") |
|
319 | + || !$relatedModel->isCachable() |
|
320 | 320 | ) { |
321 | 321 | return false; |
322 | 322 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | } |
328 | 328 | |
329 | 329 | return $this->isCachable |
330 | - && ! $isCacheDisabled |
|
330 | + && !$isCacheDisabled |
|
331 | 331 | && $allRelationshipsAreCachable; |
332 | 332 | } |
333 | 333 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at"; |
339 | 339 | |
340 | 340 | $instance->cache() |
341 | - ->rememberForever($cacheKey, function () { |
|
341 | + ->rememberForever($cacheKey, function() { |
|
342 | 342 | return (new Carbon)->now(); |
343 | 343 | }); |
344 | 344 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | protected function getBindingsSlug() : string |
61 | 61 | { |
62 | - if (! method_exists($this->model, 'query')) { |
|
62 | + if (!method_exists($this->model, 'query')) { |
|
63 | 63 | return ''; |
64 | 64 | } |
65 | 65 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | protected function getInAndNotInClauses(array $where) : string |
97 | 97 | { |
98 | - if (! in_array($where["type"], ["In", "NotIn", "InRaw"])) { |
|
98 | + if (!in_array($where["type"], ["In", "NotIn", "InRaw"])) { |
|
99 | 99 | return ""; |
100 | 100 | } |
101 | 101 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $this->currentBinding += count($where["values"]); |
108 | 108 | } |
109 | 109 | |
110 | - if (! is_numeric($subquery) && ! is_numeric(str_replace("_", "", $subquery))) { |
|
110 | + if (!is_numeric($subquery) && !is_numeric(str_replace("_", "", $subquery))) { |
|
111 | 111 | try { |
112 | 112 | $subquery = Uuid::fromBytes($subquery); |
113 | 113 | $values = $this->recursiveImplode([$subquery], "_"); |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | |
128 | 128 | protected function getLimitClause() : string |
129 | 129 | { |
130 | - if (! property_exists($this->query, "limit") |
|
131 | - || ! $this->query->limit |
|
130 | + if (!property_exists($this->query, "limit") |
|
131 | + || !$this->query->limit |
|
132 | 132 | ) { |
133 | 133 | return ""; |
134 | 134 | } |
@@ -143,17 +143,17 @@ discard block |
||
143 | 143 | |
144 | 144 | protected function getNestedClauses(array $where) : string |
145 | 145 | { |
146 | - if (! in_array($where["type"], ["Exists", "Nested", "NotExists"])) { |
|
146 | + if (!in_array($where["type"], ["Exists", "Nested", "NotExists"])) { |
|
147 | 147 | return ""; |
148 | 148 | } |
149 | 149 | |
150 | - return "-" . strtolower($where["type"]) . $this->getWhereClauses($where["query"]->wheres); |
|
150 | + return "-".strtolower($where["type"]).$this->getWhereClauses($where["query"]->wheres); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | protected function getOffsetClause() : string |
154 | 154 | { |
155 | - if (! property_exists($this->query, "offset") |
|
156 | - || ! $this->query->offset |
|
155 | + if (!property_exists($this->query, "offset") |
|
156 | + || !$this->query->offset |
|
157 | 157 | ) { |
158 | 158 | return ""; |
159 | 159 | } |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | |
164 | 164 | protected function getOrderByClauses() : string |
165 | 165 | { |
166 | - if (! property_exists($this->query, "orders") |
|
167 | - || ! $this->query->orders |
|
166 | + if (!property_exists($this->query, "orders") |
|
167 | + || !$this->query->orders |
|
168 | 168 | ) { |
169 | 169 | return ""; |
170 | 170 | } |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | $orders = collect($this->query->orders); |
173 | 173 | |
174 | 174 | return $orders |
175 | - ->reduce(function ($carry, $order) { |
|
175 | + ->reduce(function($carry, $order) { |
|
176 | 176 | if (($order["type"] ?? "") === "Raw") { |
177 | - return $carry . "_orderByRaw_" . (new Str)->slug($order["sql"]); |
|
177 | + return $carry."_orderByRaw_".(new Str)->slug($order["sql"]); |
|
178 | 178 | } |
179 | 179 | |
180 | - return $carry . "_orderBy_" . $order["column"] . "_" . $order["direction"]; |
|
180 | + return $carry."_orderBy_".$order["column"]."_".$order["direction"]; |
|
181 | 181 | }) |
182 | 182 | ?: ""; |
183 | 183 | } |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | { |
203 | 203 | if (($columns === ["*"] |
204 | 204 | || $columns === []) |
205 | - && (! property_exists($this->query, "columns") |
|
206 | - || ! $this->query->columns) |
|
205 | + && (!property_exists($this->query, "columns") |
|
206 | + || !$this->query->columns) |
|
207 | 207 | ) { |
208 | 208 | return ""; |
209 | 209 | } |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | if (property_exists($this->query, "columns") |
212 | 212 | && $this->query->columns |
213 | 213 | ) { |
214 | - return "_" . implode("_", $this->query->columns); |
|
214 | + return "_".implode("_", $this->query->columns); |
|
215 | 215 | } |
216 | 216 | |
217 | - return "_" . implode("_", $columns); |
|
217 | + return "_".implode("_", $columns); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | protected function getRawClauses(array $where) : string |
221 | 221 | { |
222 | - if (! in_array($where["type"], ["raw"])) { |
|
222 | + if (!in_array($where["type"], ["raw"])) { |
|
223 | 223 | return ""; |
224 | 224 | } |
225 | 225 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $clause = "_{$where["boolean"]}"; |
228 | 228 | |
229 | 229 | while (count($queryParts) > 1) { |
230 | - $clause .= "_" . array_shift($queryParts); |
|
230 | + $clause .= "_".array_shift($queryParts); |
|
231 | 231 | $clause .= $this->getCurrentBinding("where"); |
232 | 232 | $this->currentBinding++; |
233 | 233 | } |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | $lastPart = array_shift($queryParts); |
236 | 236 | |
237 | 237 | if ($lastPart) { |
238 | - $clause .= "_" . $lastPart; |
|
238 | + $clause .= "_".$lastPart; |
|
239 | 239 | } |
240 | 240 | |
241 | - return "-" . str_replace(" ", "_", $clause); |
|
241 | + return "-".str_replace(" ", "_", $clause); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | protected function getTableSlug() : string |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | protected function getValuesClause(array $where = []) : string |
260 | 260 | { |
261 | - if (! $where |
|
261 | + if (!$where |
|
262 | 262 | || in_array($where["type"], ["NotNull", "Null"]) |
263 | 263 | ) { |
264 | 264 | return ""; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $values = $this->getValuesFromWhere($where); |
268 | 268 | $values = $this->getValuesFromBindings($where, $values); |
269 | 269 | |
270 | - return "_" . $values; |
|
270 | + return "_".$values; |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | protected function getValuesFromWhere(array $where) : string |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | |
297 | 297 | protected function getValuesFromBindings(array $where, string $values) : string |
298 | 298 | { |
299 | - $bindingFallback = __CLASS__ . ':UNKNOWN_BINDING'; |
|
299 | + $bindingFallback = __CLASS__.':UNKNOWN_BINDING'; |
|
300 | 300 | $currentBinding = $this->getCurrentBinding("where", $bindingFallback); |
301 | 301 | |
302 | 302 | if ($currentBinding !== $bindingFallback) { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | $this->currentBinding++; |
305 | 305 | |
306 | 306 | if ($where["type"] === "between") { |
307 | - $values .= "_" . $this->getCurrentBinding("where"); |
|
307 | + $values .= "_".$this->getCurrentBinding("where"); |
|
308 | 308 | $this->currentBinding++; |
309 | 309 | } |
310 | 310 | } |
@@ -320,8 +320,8 @@ discard block |
||
320 | 320 | |
321 | 321 | protected function getWhereClauses(array $wheres = []) : string |
322 | 322 | { |
323 | - return "" . $this->getWheres($wheres) |
|
324 | - ->reduce(function ($carry, $where) { |
|
323 | + return "".$this->getWheres($wheres) |
|
324 | + ->reduce(function($carry, $where) { |
|
325 | 325 | $value = $carry; |
326 | 326 | $value .= $this->getNestedClauses($where); |
327 | 327 | $value .= $this->getColumnClauses($where); |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | return ""; |
355 | 355 | } |
356 | 356 | |
357 | - return $eagerLoads->keys()->reduce(function ($carry, $related) { |
|
358 | - if (! method_exists($this->model, $related)) { |
|
357 | + return $eagerLoads->keys()->reduce(function($carry, $related) { |
|
358 | + if (!method_exists($this->model, $related)) { |
|
359 | 359 | return "{$carry}-{$related}"; |
360 | 360 | } |
361 | 361 | |
@@ -387,13 +387,13 @@ discard block |
||
387 | 387 | continue; |
388 | 388 | } |
389 | 389 | |
390 | - $result .= $glue . $value; |
|
390 | + $result .= $glue.$value; |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | return $result; |
394 | 394 | } |
395 | 395 | |
396 | - private function processEnum(\BackedEnum|\UnitEnum|string $value): string |
|
396 | + private function processEnum(\BackedEnum | \UnitEnum | string $value): string |
|
397 | 397 | { |
398 | 398 | if ($value instanceof \BackedEnum) { |
399 | 399 | return $value->value; |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | $key = $instance->makeCacheKey(); |
52 | 52 | |
53 | 53 | return $instance->cache($tags) |
54 | - ->rememberForever($key, function () use ($columns) { |
|
54 | + ->rememberForever($key, function() use ($columns) { |
|
55 | 55 | return parent::all($columns); |
56 | 56 | }); |
57 | 57 | } |
58 | 58 | |
59 | 59 | public static function bootCachable() |
60 | 60 | { |
61 | - static::created(function ($instance) { |
|
61 | + static::created(function($instance) { |
|
62 | 62 | $instance->checkCooldownAndFlushAfterPersisting($instance); |
63 | 63 | }); |
64 | 64 | |
65 | - static::deleted(function ($instance) { |
|
65 | + static::deleted(function($instance) { |
|
66 | 66 | $instance->checkCooldownAndFlushAfterPersisting($instance); |
67 | 67 | }); |
68 | 68 | |
69 | - static::saved(function ($instance) { |
|
69 | + static::saved(function($instance) { |
|
70 | 70 | $instance->checkCooldownAndFlushAfterPersisting($instance); |
71 | 71 | }); |
72 | 72 | |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | // $instance->checkCooldownAndFlushAfterPersisting($instance); |
76 | 76 | // }); |
77 | 77 | |
78 | - static::pivotSynced(function ($instance, $secondInstance, $relationship) { |
|
78 | + static::pivotSynced(function($instance, $secondInstance, $relationship) { |
|
79 | 79 | $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship); |
80 | 80 | }); |
81 | 81 | |
82 | - static::pivotAttached(function ($instance, $secondInstance, $relationship) { |
|
82 | + static::pivotAttached(function($instance, $secondInstance, $relationship) { |
|
83 | 83 | $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship); |
84 | 84 | }); |
85 | 85 | |
86 | - static::pivotDetached(function ($instance, $secondInstance, $relationship) { |
|
86 | + static::pivotDetached(function($instance, $secondInstance, $relationship) { |
|
87 | 87 | $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship); |
88 | 88 | }); |
89 | 89 | |
90 | - static::pivotUpdated(function ($instance, $secondInstance, $relationship) { |
|
90 | + static::pivotUpdated(function($instance, $secondInstance, $relationship) { |
|
91 | 91 | $instance->checkCooldownAndFlushAfterPersisting($instance, $relationship); |
92 | 92 | }); |
93 | 93 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | public function newEloquentBuilder($query) |
105 | 105 | { |
106 | - if (! $this->isCachable()) { |
|
106 | + if (!$this->isCachable()) { |
|
107 | 107 | $this->isCachable = false; |
108 | 108 | |
109 | 109 | return new EloquentBuilder($query); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | EloquentBuilder $query, |
163 | 163 | int $seconds = null |
164 | 164 | ) : EloquentBuilder { |
165 | - if (! $seconds) { |
|
165 | + if (!$seconds) { |
|
166 | 166 | $seconds = $this->cacheCooldownSeconds; |
167 | 167 | } |
168 | 168 | |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:seconds"; |
172 | 172 | |
173 | 173 | $this->cache() |
174 | - ->rememberForever($cacheKey, function () use ($seconds) { |
|
174 | + ->rememberForever($cacheKey, function() use ($seconds) { |
|
175 | 175 | return $seconds; |
176 | 176 | }); |
177 | 177 | |
178 | 178 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at"; |
179 | 179 | $this->cache() |
180 | - ->rememberForever($cacheKey, function () { |
|
180 | + ->rememberForever($cacheKey, function() { |
|
181 | 181 | return (new Carbon)->now(); |
182 | 182 | }); |
183 | 183 |