I have 1 table/model: Persons
. Each Person
is of a type ("student","employee","instructor"). Each of these types has extra pieces of information, so I have person_student
, person_employee
, person_instructor
tables (and associated models) as well.
I know I can set up a relationship between my Person model and PersonStudent/PersonEmployee/PersonInstructor model, but I was wondering if there was a way in the ORM to set up a relationship so that I could refer to the additional models using 1 single alias, regardless of what additional model is actually being related.
So for example, if I have a student record, I'd like to be able to reference $Person->Additional
and have Additional
refer to a PersonStudent
record. Similarly if I have an employee record, I'd like to have $Person->Additional
refer to a PersonEmployee
record.
I'm pretty sure I could do this in straight PHP, by overriding __get()
, or possibly just using $Person->Additional()
, and having the Additional()
method reference the respective objects. Still - I'm wondering if Phalcon has anything that could help me.