File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ protected static function decodeVirtualColumn(self $model): void
3030
3131 foreach ($ model ->getAttribute (static ::getDataColumn ()) ?? [] as $ key => $ value ) {
3232 $ model ->setAttribute ($ key , $ value );
33+ $ model ->syncOriginalAttribute ($ key );
3334 }
3435
3536 $ model ->setAttribute (static ::getDataColumn (), null );
@@ -52,6 +53,7 @@ protected static function encodeAttributes(self $model): void
5253 ]));
5354
5455 unset($ model ->attributes [$ key ]);
56+ unset($ model ->original [$ key ]);
5557 }
5658 }
5759
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ public function keys_which_dont_have_their_own_column_go_into_data_json_column()
3434 // Model has the correct structure when retrieved
3535 $ model = MyModel::first ();
3636 $ this ->assertSame ('bar ' , $ model ->foo );
37+ $ this ->assertSame ('bar ' , $ model ->getOriginal ('foo ' ));
3738 $ this ->assertSame (null , $ model ->data );
3839
3940 // Model can be updated
@@ -43,7 +44,9 @@ public function keys_which_dont_have_their_own_column_go_into_data_json_column()
4344 ]);
4445
4546 $ this ->assertSame ('baz ' , $ model ->foo );
47+ $ this ->assertSame ('baz ' , $ model ->getOriginal ('foo ' ));
4648 $ this ->assertSame ('xyz ' , $ model ->abc );
49+ $ this ->assertSame ('xyz ' , $ model ->getOriginal ('abc ' ));
4750 $ this ->assertSame (null , $ model ->data );
4851
4952 // Model can be retrieved after update & is structure correctly
You can’t perform that action at this time.
0 commit comments