1- <?php namespace GeneaLabs \LaravelModelCaching \Traits ;
1+ <?php
2+
3+ namespace GeneaLabs \LaravelModelCaching \Traits ;
24
35use Closure ;
46use GeneaLabs \LaravelModelCaching \CachedBuilder ;
@@ -45,15 +47,19 @@ public function applyScopes()
4547
4648 protected function applyScopesToInstance ()
4749 {
48- if (! property_exists ($ this , "scopes " )
50+ if (
51+ ! property_exists ($ this , "scopes " )
4952 || $ this ->scopesAreApplied
5053 || $ this ->withoutAllGlobalScopes
5154 ) {
5255 return ;
5356 }
5457
5558 foreach ($ this ->scopes as $ identifier => $ scope ) {
56- if (! isset ($ this ->scopes [$ identifier ]) || isset ($ this ->withoutGlobalScopes [$ identifier ])) {
59+ if (
60+ ! isset ($ this ->scopes [$ identifier ])
61+ || isset ($ this ->withoutGlobalScopes [$ identifier ])
62+ ) {
5763 continue ;
5864 }
5965
@@ -62,7 +68,8 @@ protected function applyScopesToInstance()
6268 $ scope ($ this );
6369 }
6470
65- if ($ scope instanceof Scope
71+ if (
72+ $ scope instanceof Scope
6673 && $ this instanceof CachedBuilder
6774 ) {
6875 $ scope ->apply ($ this , $ this ->getModel ());
@@ -127,7 +134,8 @@ protected function getCachePrefix() : string
127134 ->make ("config " )
128135 ->get ("laravel-model-caching.cache-prefix " , "" );
129136
130- if ($ this ->model
137+ if (
138+ $ this ->model
131139 && property_exists ($ this ->model , "cachePrefix " )
132140 ) {
133141 $ cachePrefix = $ this ->model ->cachePrefix ;
@@ -163,7 +171,8 @@ protected function makeCacheKey(
163171 ->make ("db " )
164172 ->query ();
165173
166- if ($ this ->query
174+ if (
175+ $ this ->query
167176 && method_exists ($ this ->query , "getQuery " )
168177 ) {
169178 $ query = $ this ->query ->getQuery ();
@@ -230,7 +239,8 @@ protected function checkCooldownAndRemoveIfExpired(Model $instance)
230239 {
231240 [$ cacheCooldown , $ invalidatedAt ] = $ this ->getModelCacheCooldown ($ instance );
232241
233- if (! $ cacheCooldown
242+ if (
243+ ! $ cacheCooldown
234244 || (new Carbon )->now ()->diffInSeconds ($ invalidatedAt ) < $ cacheCooldown
235245 ) {
236246 return ;
@@ -287,22 +297,25 @@ public function isCachable() : bool
287297 ->get ("laravel-model-caching.enabled " );
288298 $ allRelationshipsAreCachable = true ;
289299
290- if (property_exists ($ this , "eagerLoad " )
300+ if (
301+ property_exists ($ this , "eagerLoad " )
291302 && $ this ->eagerLoad
292303 ) {
293304 $ allRelationshipsAreCachable = collect ($ this
294305 ->eagerLoad )
295306 ->keys ()
296307 ->reduce (function ($ carry , $ related ) {
297- if (! method_exists ($ this ->model , $ related )
308+ if (
309+ ! method_exists ($ this ->model , $ related )
298310 || $ carry === false
299311 ) {
300312 return $ carry ;
301313 }
302314
303315 $ relatedModel = $ this ->model ->$ related ()->getRelated ();
304316
305- if (! method_exists ($ relatedModel , "isCachable " )
317+ if (
318+ ! method_exists ($ relatedModel , "isCachable " )
306319 || ! $ relatedModel ->isCachable ()
307320 ) {
308321 return false ;
0 commit comments