yii2-cookbook
yii2-cookbook copied to clipboard
Topic Request: Relations with STI
Hi Samdark,
I was reading through the cookbook's Single Table Inheritance article and found it very useful, but I noticed it's missing one key part: dealing with relations.
It would be great if you could add an explanation on how to declare relations from a regular AR to a STI AR and vice versa. For example, in the article there is a Car
AR. Could we add for example a hypothetical AR called Vendor
which has a getCars()
(and maybe getSportCars()
, getHeavyCars()
) relation(s) pointing to Car
? And then a hasOne getVendor()
relation in Car
pointing back to Vendor
. Maybe briefly touch on how inverseOf
would work in that case.