File tree Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Original file line number Diff line number Diff line change 1111trait Cachable
1212{
1313 protected $ isCachable = true ;
14- protected static $ isCachableKey = 'genealabs:laravel-model-caching:is-disabled ' ;
1514
1615 protected function cache (array $ tags = [])
1716 {
@@ -43,8 +42,6 @@ protected function addTagsWhenCalledFromCachedBuilder(array $tags) : array
4342
4443 public function disableCache ()
4544 {
46- cache ()->forever (self ::$ isCachableKey , true );
47-
4845 $ this ->isCachable = false ;
4946
5047 return $ this ;
@@ -89,10 +86,6 @@ public static function bootCachable()
8986
9087 public static function all ($ columns = ['* ' ])
9188 {
92- if (! cache ()->get (self ::$ isCachableKey )) {
93- return parent ::all ($ columns );
94- }
95-
9689 $ class = get_called_class ();
9790 $ instance = new $ class ;
9891 $ tags = [str_slug (get_called_class ())];
@@ -106,8 +99,8 @@ public static function all($columns = ['*'])
10699
107100 public function newEloquentBuilder ($ query )
108101 {
109- if (cache ()-> get ( self :: $ isCachableKey ) ) {
110- cache ()-> forget ( self :: $ isCachableKey ) ;
102+ if (! $ this -> isCachable ) {
103+ $ this -> isCachable = true ;
111104
112105 return new EloquentBuilder ($ query );
113106 }
You can’t perform that action at this time.
0 commit comments