File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,7 @@ protected function addUpdatedAtColumn(array $values)
328328 if (array_key_exists ('$set ' , $ values ) && array_key_exists ($ column , $ values ['$set ' ])) {
329329 return $ values ;
330330 }
331+
331332 $ values = array_replace (
332333 [$ column => $ this ->model ->freshTimestampString ()],
333334 $ values ,
Original file line number Diff line number Diff line change @@ -169,6 +169,21 @@ public function testUpdate(): void
169169 $ this ->assertEquals ('Hans Thomas ' , $ check ->fullname );
170170 }
171171
172+ public function testUpdateTroughSetUpdatedAt (): void
173+ {
174+ $ user = new User ();
175+ $ user ->name = 'John Doe ' ;
176+ $ user ->title = 'admin ' ;
177+ $ user ->age = 35 ;
178+ $ user ->save ();
179+
180+ $ updatedAt = Carbon::yesterday ();
181+ User::query ()->update (['$set ' => ['updated_at ' => new UTCDateTime ($ updatedAt )]]);
182+
183+ $ check = User::find ($ user ->id );
184+ $ this ->assertEquals ($ updatedAt , $ check ->updated_at );
185+ }
186+
172187 public function testUpsert ()
173188 {
174189 $ result = User::upsert ([
You can’t perform that action at this time.
0 commit comments