File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -23,13 +23,13 @@ public function avg($column)
23
23
return $ this ->cachedValue (func_get_args (), $ cacheKey );
24
24
}
25
25
26
- public function count ($ columns = [ "* " ] )
26
+ public function count ($ columns = "* " )
27
27
{
28
28
if (! $ this ->isCachable ()) {
29
29
return parent ::count ($ columns );
30
30
}
31
31
32
- $ cacheKey = $ this ->makeCacheKey ($ columns , null , "-count " );
32
+ $ cacheKey = $ this ->makeCacheKey ([ $ columns] , null , "-count " );
33
33
34
34
return $ this ->cachedValue (func_get_args (), $ cacheKey );
35
35
}
Original file line number Diff line number Diff line change @@ -243,6 +243,28 @@ public function testCountModelResultsCreatesCache()
243
243
$ this ->assertEquals ($ liveResults , $ cachedResults );
244
244
}
245
245
246
+ public function testCountWithStringCreatesCache ()
247
+ {
248
+ $ authors = (new Author )
249
+ ->with ('books ' , 'profile ' )
250
+ ->count ("id " );
251
+ $ key = sha1 ('genealabs:laravel-model-caching:testing:genealabslaravelmodelcachingtestsfixturesauthor_id-books-profile-count ' );
252
+ $ tags = [
253
+ 'genealabs:laravel-model-caching:testing:genealabslaravelmodelcachingtestsfixturesauthor ' ,
254
+ 'genealabs:laravel-model-caching:testing:genealabslaravelmodelcachingtestsfixturesbook ' ,
255
+ 'genealabs:laravel-model-caching:testing:genealabslaravelmodelcachingtestsfixturesprofile ' ,
256
+ ];
257
+
258
+ $ cachedResults = $ this ->cache ()->tags ($ tags )
259
+ ->get ($ key )['value ' ];
260
+ $ liveResults = (new UncachedAuthor )
261
+ ->with ('books ' , 'profile ' )
262
+ ->count ("id " );
263
+
264
+ $ this ->assertEquals ($ authors , $ cachedResults );
265
+ $ this ->assertEquals ($ liveResults , $ cachedResults );
266
+ }
267
+
246
268
public function testFindModelResultsCreatesCache ()
247
269
{
248
270
$ author = collect ()->push ((new Author )->find (1 ));
You can’t perform that action at this time.
0 commit comments