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)
328
328
if (array_key_exists ('$set ' , $ values ) && array_key_exists ($ column , $ values ['$set ' ])) {
329
329
return $ values ;
330
330
}
331
+
331
332
$ values = array_replace (
332
333
[$ column => $ this ->model ->freshTimestampString ()],
333
334
$ values ,
Original file line number Diff line number Diff line change @@ -169,6 +169,21 @@ public function testUpdate(): void
169
169
$ this ->assertEquals ('Hans Thomas ' , $ check ->fullname );
170
170
}
171
171
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
+
172
187
public function testUpsert ()
173
188
{
174
189
$ result = User::upsert ([
You can’t perform that action at this time.
0 commit comments