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 @@ -325,6 +325,10 @@ protected function addUpdatedAtColumn(array $values)
325
325
}
326
326
327
327
$ column = $ this ->model ->getUpdatedAtColumn ();
328
+ if (isset ($ values ['$set ' ][$ column ])) {
329
+ return $ values ;
330
+ }
331
+
328
332
$ values = array_replace (
329
333
[$ column => $ this ->model ->freshTimestampString ()],
330
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
+ $ 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