File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ public function testEmpty() : void
2929 $ this ->assertFalse (empty ($ order ->employee ));
3030 $ this ->assertFalse (empty ($ order ->employee_id ));
3131 $ order ->employee = new \Tests \Fixtures \Record \Employee ();
32+ $ this ->assertTrue ($ order ->employee ->empty ());
33+ $ this ->assertFalse ($ order ->employee ->loaded ());
3234 $ this ->assertTrue (empty ($ order ->employee ));
3335 $ this ->assertNull ($ order ->employee_id );
3436 }
Original file line number Diff line number Diff line change @@ -128,6 +128,17 @@ public function __get(string $field) : mixed
128128 return $ this ->current [$ field ] ?? null ;
129129 }
130130
131+ // could be a related record, see if has a matching Id
132+ if (\array_key_exists ($ field . \PHPFUI \ORM ::$ idSuffix , static ::$ fields ))
133+ {
134+ $ type = '\\' . \PHPFUI \ORM ::$ recordNamespace . '\\' . \PHPFUI \ORM ::getBaseClassName ($ field );
135+
136+ if (\class_exists ($ type ))
137+ {
138+ return new $ type ($ this ->current [$ field . \PHPFUI \ORM ::$ idSuffix ]);
139+ }
140+ }
141+
131142 return parent ::__get ($ field );
132143 }
133144
You can’t perform that action at this time.
0 commit comments