私は次のDB関係を持っています:
Building hasMany Shape
Appartment hasOne Shape
Building hasMany Appartment
Shape belongsTo Building & Appartment
ここで、Shapeモデルで、特定の建物に属するすべての形状を取得したいと思います。これには、この特定の建物に属するアパートに属する形状が含まれます。
例えば
Building 'X'
There are 4 shapes directly linked to building X via the belongsTo Building relation.
Shape->Building
And there are 2 shapes directly linked to 2 appartments via the belongsTo Appartment relation. These 2 appartments again are directly linked to Building X via the belongsTo Building relation. Thus these 2 shapes are indirectly linked to building X.
Shape->Appartment->Building
私はこれに頭を悩ませているようには見えません、助けていただければ幸いです。