File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,36 @@ public function __get(string $key)
4848 return null ;
4949 }
5050
51+ /**
52+ * Complimentary property checker to __get()
53+ *
54+ * @param string $key The name of the requested property, i.e. table to check for relations
55+ *
56+ * @return bool Whether the entity property or table relation exists
57+ */
58+ public function __isset (string $ key ): bool
59+ {
60+ // First check the framework's version
61+ if (parent ::__isset ($ key ))
62+ {
63+ return true ;
64+ }
65+
66+ // Get the schema
67+ $ schema = $ this ->_schema ();
68+
69+ // Convert the key to table format
70+ $ tableName = plural (strtolower ($ key ));
71+
72+ // Check for a matching table
73+ if (isset ($ schema ->tables ->$ tableName ))
74+ {
75+ return true ;
76+ }
77+
78+ return false ;
79+ }
80+
5181 /**
5282 * Intercept undefined methods and check them against known relations
5383 *
You can’t perform that action at this time.
0 commit comments