@@ -375,7 +375,7 @@ class Model {
375375 */
376376 public function __sleep () {
377377 # Variables
378- $ excluded_properties = ['initial_object ' , 'client ' , 'parent_model ' , 'related_objects ' ];
378+ $ excluded_properties = ['initial_object ' , 'client ' , 'parent_model ' , 'related_objects ' , ' object_cache ' ];
379379 $ properties = array_keys (get_object_vars ($ this ));
380380
381381 # Filter out excluded properties from the list of properties to serialize
@@ -880,8 +880,11 @@ class Model {
880880 foreach ($ parent_configs as $ parent_id => $ parent_config ) {
881881 # Obtain the list of child objects from this parent config
882882 $ child_configs = $ this ->get_config ("$ parent_model ->config_path / $ parent_id/ $ this ->config_path " , []);
883+ $ parent_model = new $ parent_model_class (id: $ parent_id , skip_init: true );
884+ $ parent_model ->from_internal_object ($ parent_config );
883885
884886 foreach ($ child_configs as $ child_id => $ child_config ) {
887+ $ child_config ['parent_model ' ] = $ parent_model ;
885888 $ child_config ['parent_id ' ] = $ parent_id ;
886889 $ child_config ['id ' ] = $ child_id ;
887890 $ internal_objects [] = $ child_config ;
@@ -1800,10 +1803,10 @@ class Model {
18001803
18011804 # Obtain all Model objects for this Model and sort them by the requested criteria
18021805 $ modelset = $ this ->query (
1803- parent_id: $ this ->parent_id ,
18041806 sort_by: $ this ->sort_by ,
18051807 sort_order: $ this ->sort_order ,
18061808 sort_flags: $ this ->sort_flags ,
1809+ parent_id: $ this ->parent_id ,
18071810 );
18081811
18091812 # Loop through the sorted object and assign it's internal value
@@ -1969,12 +1972,11 @@ class Model {
19691972
19701973 # Create a new Model object for this internal object and assign its ID
19711974 $ model_object = new $ model (id: $ internal_id , parent_id: $ parent_id , skip_init: true );
1972-
1973- # Obtain the parent Model object if this Model has a parent Model class assigned
1974- $ model_object ->parent_model = $ model ->parent_model ;
1975+ $ model_object ->parent_model = $ internal_object ['parent_model ' ] ?? null ;
19751976
19761977 # Populate the Model object using its current internal values and add it to the array of all Model objects
19771978 $ model_object ->from_internal_object ($ internal_object );
1979+
19781980 $ model_objects [] = $ model_object ;
19791981 }
19801982
0 commit comments