File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 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)
3838 $ term ->data ($ data );
3939
4040 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 );
4244 }
4345
4446 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()
2929 $ this ->assertCount (1 , TermModel::all ());
3030 $ this ->assertSame ('new-slug ' , TermModel::first ()->slug );
3131 }
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+ }
3250}
You can’t perform that action at this time.
0 commit comments