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
29
29
$ this ->assertFalse (empty ($ order ->employee ));
30
30
$ this ->assertFalse (empty ($ order ->employee_id ));
31
31
$ order ->employee = new \Tests \Fixtures \Record \Employee ();
32
+ $ this ->assertTrue ($ order ->employee ->empty ());
33
+ $ this ->assertFalse ($ order ->employee ->loaded ());
32
34
$ this ->assertTrue (empty ($ order ->employee ));
33
35
$ this ->assertNull ($ order ->employee_id );
34
36
}
Original file line number Diff line number Diff line change @@ -128,6 +128,17 @@ public function __get(string $field) : mixed
128
128
return $ this ->current [$ field ] ?? null ;
129
129
}
130
130
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
+
131
142
return parent ::__get ($ field );
132
143
}
133
144
You can’t perform that action at this time.
0 commit comments