@@ -16,11 +16,9 @@ public function avg($column)
16
16
return parent ::avg ($ column );
17
17
}
18
18
19
- $ arguments = func_get_args ();
20
19
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-avg_ {$ column }" );
21
- $ method = "avg " ;
22
20
23
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
21
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
24
22
}
25
23
26
24
public function count ($ columns = ["* " ])
@@ -29,11 +27,9 @@ public function count($columns = ["*"])
29
27
return parent ::count ($ columns );
30
28
}
31
29
32
- $ arguments = func_get_args ();
33
- $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-count " );
34
- $ method = "count " ;
30
+ $ cacheKey = $ this ->makeCacheKey ($ columns , null , "-count " );
35
31
36
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
32
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
37
33
}
38
34
39
35
public function cursor ()
@@ -42,11 +38,9 @@ public function cursor()
42
38
return collect (parent ::cursor ());
43
39
}
44
40
45
- $ arguments = func_get_args ();
46
41
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-cursor " );
47
- $ method = "cursor " ;
48
42
49
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
43
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
50
44
}
51
45
52
46
public function delete ()
@@ -66,11 +60,9 @@ public function find($id, $columns = ["*"])
66
60
return parent ::find ($ id , $ columns );
67
61
}
68
62
69
- $ arguments = func_get_args ();
70
- $ cacheKey = $ this ->makeCacheKey (["* " ], null , "-find_ {$ id }" );
71
- $ method = "find " ;
63
+ $ cacheKey = $ this ->makeCacheKey ($ columns , null , "-find_ {$ id }" );
72
64
73
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
65
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
74
66
}
75
67
76
68
public function first ($ columns = ["* " ])
@@ -79,11 +71,9 @@ public function first($columns = ["*"])
79
71
return parent ::first ($ columns );
80
72
}
81
73
82
- $ arguments = func_get_args ();
83
74
$ cacheKey = $ this ->makeCacheKey ($ columns );
84
- $ method = "first " ;
85
75
86
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
76
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
87
77
}
88
78
89
79
public function get ($ columns = ["* " ])
@@ -92,11 +82,9 @@ public function get($columns = ["*"])
92
82
return parent ::get ($ columns );
93
83
}
94
84
95
- $ arguments = func_get_args ();
96
85
$ cacheKey = $ this ->makeCacheKey ($ columns );
97
- $ method = "get " ;
98
86
99
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
87
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
100
88
}
101
89
102
90
public function max ($ column )
@@ -105,11 +93,9 @@ public function max($column)
105
93
return parent ::max ($ column );
106
94
}
107
95
108
- $ arguments = func_get_args ();
109
96
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-max_ {$ column }" );
110
- $ method = "max " ;
111
97
112
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
98
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
113
99
}
114
100
115
101
public function min ($ column )
@@ -118,11 +104,9 @@ public function min($column)
118
104
return parent ::min ($ column );
119
105
}
120
106
121
- $ arguments = func_get_args ();
122
107
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-min_ {$ column }" );
123
- $ method = "min " ;
124
108
125
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
109
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
126
110
}
127
111
128
112
public function paginate (
@@ -135,12 +119,10 @@ public function paginate(
135
119
return parent ::paginate ($ perPage , $ columns , $ pageName , $ page );
136
120
}
137
121
138
- $ arguments = func_get_args ();
139
122
$ page = $ page ?: 1 ;
140
123
$ cacheKey = $ this ->makeCacheKey ($ columns , null , "-paginate_by_ {$ perPage }_ {$ pageName }_ {$ page }" );
141
- $ method = "paginate " ;
142
124
143
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
125
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
144
126
}
145
127
146
128
public function pluck ($ column , $ key = null )
@@ -150,11 +132,9 @@ public function pluck($column, $key = null)
150
132
}
151
133
152
134
$ keyDifferentiator = "-pluck_ {$ column }" . ($ key ? "_ {$ key }" : "" );
153
- $ arguments = func_get_args ();
154
135
$ cacheKey = $ this ->makeCacheKey ([$ column ], null , $ keyDifferentiator );
155
- $ method = "pluck " ;
156
136
157
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
137
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
158
138
}
159
139
160
140
public function sum ($ column )
@@ -163,11 +143,9 @@ public function sum($column)
163
143
return parent ::sum ($ column );
164
144
}
165
145
166
- $ arguments = func_get_args ();
167
146
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-sum_ {$ column }" );
168
- $ method = "sum " ;
169
147
170
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
148
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
171
149
}
172
150
173
151
public function value ($ column )
@@ -176,15 +154,14 @@ public function value($column)
176
154
return parent ::value ($ column );
177
155
}
178
156
179
- $ arguments = func_get_args ();
180
157
$ cacheKey = $ this ->makeCacheKey (["* " ], null , "-value_ {$ column }" );
181
- $ method = "value " ;
182
158
183
- return $ this ->cachedValue ($ arguments , $ cacheKey, $ method );
159
+ return $ this ->cachedValue (func_get_args () , $ cacheKey );
184
160
}
185
161
186
- public function cachedValue (array $ arguments , string $ cacheKey, string $ method )
162
+ public function cachedValue (array $ arguments , string $ cacheKey )
187
163
{
164
+ $ method = debug_backtrace ()[1 ]['function ' ];
188
165
$ cacheTags = $ this ->makeCacheTags ();
189
166
$ hashedCacheKey = sha1 ($ cacheKey );
190
167
$ result = $ this ->retrieveCachedValue (
0 commit comments