File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,10 @@ protected function addUpdatedAtColumn(array $values)
310
310
}
311
311
312
312
$ column = $ this ->model ->getUpdatedAtColumn ();
313
+ if (isset ($ values ['$set ' ][$ column ])) {
314
+ return $ values ;
315
+ }
316
+
313
317
$ values = array_replace (
314
318
[$ column => $ this ->model ->freshTimestampString ()],
315
319
$ 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
+ $ user ->refresh ();
184
+ $ this ->assertEquals ($ updatedAt , $ user ->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