File tree 2 files changed +27
-0
lines changed 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,13 @@ public function sum($column)
144
144
return $ this ->cachedValue (func_get_args (), $ cacheKey );
145
145
}
146
146
147
+ public function update (array $ values )
148
+ {
149
+ $ this ->checkCooldownAndFlushAfterPersiting ($ this ->model );
150
+
151
+ return parent ::update ($ values );
152
+ }
153
+
147
154
public function value ($ column )
148
155
{
149
156
if (! $ this ->isCachable ()) {
Original file line number Diff line number Diff line change @@ -909,4 +909,24 @@ public function testInsertInvalidatesCache()
909
909
$ this ->assertCount (11 , $ authorsAfterInsert );
910
910
$ this ->assertCount (11 , $ uncachedAuthors );
911
911
}
912
+
913
+ public function testUpdateInvalidatesCache ()
914
+ {
915
+ $ originalAuthor = (new Author )
916
+ ->first ();
917
+ $ author = (new Author )
918
+ ->first ();
919
+
920
+ $ author ->update ([
921
+ "name " => "Updated Name " ,
922
+ ]);
923
+ $ authorAfterUpdate = (new Author )
924
+ ->find ($ author ->id );
925
+ $ uncachedAuthor = (new UncachedAuthor )
926
+ ->find ($ author ->id );
927
+
928
+ $ this ->assertNotEquals ($ originalAuthor ->name , $ authorAfterUpdate ->name );
929
+ $ this ->assertEquals ("Updated Name " , $ authorAfterUpdate ->name );
930
+ $ this ->assertEquals ($ authorAfterUpdate ->name , $ uncachedAuthor ->name );
931
+ }
912
932
}
You can’t perform that action at this time.
0 commit comments