@@ -12,6 +12,10 @@ class CachedBuilder extends EloquentBuilder
12
12
13
13
public function avg ($ column )
14
14
{
15
+ if (! $ this ->isCachable ) {
16
+ return parent ::avg ($ column );
17
+ }
18
+
15
19
$ arguments = func_get_args ();
16
20
$ cacheKey = $ this ->makeCacheKey (['* ' ], null , "-avg_ {$ column }" );
17
21
$ method = 'avg ' ;
@@ -21,6 +25,10 @@ public function avg($column)
21
25
22
26
public function count ($ columns = ['* ' ])
23
27
{
28
+ if (! $ this ->isCachable ) {
29
+ return parent ::count ($ columns );
30
+ }
31
+
24
32
$ arguments = func_get_args ();
25
33
$ cacheKey = $ this ->makeCacheKey (['* ' ], null , "-count " );
26
34
$ method = 'count ' ;
@@ -30,6 +38,10 @@ public function count($columns = ['*'])
30
38
31
39
public function cursor ()
32
40
{
41
+ if (! $ this ->isCachable ) {
42
+ return collect (parent ::cursor ());
43
+ }
44
+
33
45
$ arguments = func_get_args ();
34
46
$ cacheKey = $ this ->makeCacheKey (['* ' ], null , "-cursor " );
35
47
$ method = 'cursor ' ;
@@ -50,6 +62,10 @@ public function delete()
50
62
*/
51
63
public function find ($ id , $ columns = ['* ' ])
52
64
{
65
+ if (! $ this ->isCachable ) {
66
+ return parent ::find ($ id , $ columns );
67
+ }
68
+
53
69
$ arguments = func_get_args ();
54
70
$ cacheKey = $ this ->makeCacheKey ($ columns );
55
71
$ method = 'find ' ;
@@ -59,6 +75,10 @@ public function find($id, $columns = ['*'])
59
75
60
76
public function first ($ columns = ['* ' ])
61
77
{
78
+ if (! $ this ->isCachable ) {
79
+ return parent ::first ($ columns );
80
+ }
81
+
62
82
$ arguments = func_get_args ();
63
83
$ cacheKey = $ this ->makeCacheKey ($ columns );
64
84
$ method = 'first ' ;
@@ -68,6 +88,10 @@ public function first($columns = ['*'])
68
88
69
89
public function get ($ columns = ['* ' ])
70
90
{
91
+ if (! $ this ->isCachable ) {
92
+ return parent ::get ($ columns );
93
+ }
94
+
71
95
$ arguments = func_get_args ();
72
96
$ cacheKey = $ this ->makeCacheKey ($ columns );
73
97
$ method = 'get ' ;
@@ -77,6 +101,10 @@ public function get($columns = ['*'])
77
101
78
102
public function max ($ column )
79
103
{
104
+ if (! $ this ->isCachable ) {
105
+ return parent ::max ($ column );
106
+ }
107
+
80
108
$ arguments = func_get_args ();
81
109
$ cacheKey = $ this ->makeCacheKey (['* ' ], null , "-max_ {$ column }" );
82
110
$ method = 'max ' ;
@@ -86,6 +114,10 @@ public function max($column)
86
114
87
115
public function min ($ column )
88
116
{
117
+ if (! $ this ->isCachable ) {
118
+ return parent ::min ($ column );
119
+ }
120
+
89
121
$ arguments = func_get_args ();
90
122
$ cacheKey = $ this ->makeCacheKey (['* ' ], null , "-min_ {$ column }" );
91
123
$ method = 'min ' ;
@@ -95,6 +127,10 @@ public function min($column)
95
127
96
128
public function pluck ($ column , $ key = null )
97
129
{
130
+ if (! $ this ->isCachable ) {
131
+ return parent ::pluck ($ column , $ key );
132
+ }
133
+
98
134
$ keyDifferentiator = "-pluck_ {$ column }" . ($ key ? "_ {$ key }" : "" );
99
135
$ arguments = func_get_args ();
100
136
$ cacheKey = $ this ->makeCacheKey ([$ column ], null , $ keyDifferentiator );
@@ -105,6 +141,10 @@ public function pluck($column, $key = null)
105
141
106
142
public function sum ($ column )
107
143
{
144
+ if (! $ this ->isCachable ) {
145
+ return parent ::sum ($ column );
146
+ }
147
+
108
148
$ arguments = func_get_args ();
109
149
$ cacheKey = $ this ->makeCacheKey (['* ' ], null , "-sum_ {$ column }" );
110
150
$ method = 'sum ' ;
@@ -114,6 +154,10 @@ public function sum($column)
114
154
115
155
public function value ($ column )
116
156
{
157
+ if (! $ this ->isCachable ) {
158
+ return parent ::value ($ column );
159
+ }
160
+
117
161
$ arguments = func_get_args ();
118
162
$ cacheKey = $ this ->makeCacheKey (['* ' ], null , "-value_ {$ column }" );
119
163
$ method = 'value ' ;
0 commit comments