File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,9 @@ public static function fromModel(Model $model)
38
38
$ term ->data ($ data );
39
39
40
40
if (config ('statamic.system.track_last_update ' )) {
41
- $ term ->set ('updated_at ' , $ model ->updated_at ?? $ model ->created_at );
41
+ $ updatedAt = ($ model ->updated_at ?? $ model ->created_at );
42
+
43
+ $ term ->set ('updated_at ' , $ updatedAt instanceof Carbon ? $ updatedAt ->timestamp : $ updatedAt );
42
44
}
43
45
44
46
return $ term ->syncOriginal ();
Original file line number Diff line number Diff line change @@ -29,4 +29,22 @@ public function it_doesnt_create_a_new_model_when_slug_is_changed()
29
29
$ this ->assertCount (1 , TermModel::all ());
30
30
$ this ->assertSame ('new-slug ' , TermModel::first ()->slug );
31
31
}
32
+
33
+ #[Test]
34
+ public function it_saves_updated_at_value_correctly ()
35
+ {
36
+ $ this ->freezeSecond ();
37
+
38
+ Taxonomy::make ('test ' )->title ('test ' )->save ();
39
+
40
+ tap (TermFacade::make ('test-term ' )->taxonomy ('test ' )->data ([]))->save ();
41
+
42
+ /** @var LocalizedTerm $term */
43
+ $ term = TermFacade::query ()->first ();
44
+ $ term ->set ('foo ' , 'bar ' );
45
+ $ term ->save ();
46
+
47
+ $ this ->assertEquals (now (), $ term ->updated_at );
48
+ $ this ->assertEquals (now (), TermFacade::query ()->first ()->updated_at );
49
+ }
32
50
}
You can’t perform that action at this time.
0 commit comments