标签: laravel eloquent relational-database relationship has-many-through
(Laravel 4.2)
我有以下架构
A one to many B
B one to many C
C one to one D
现在我知道hasManyThrough可用来获取A one to many C,但是我可以用它来获得“一对多D'”
hasManyThrough
A one to many C
我现在的做法是使用hasManyThrough获取C,然后使用hasOne()从C获取D.
hasOne()
还有一种方法得到反向关系,即使对于简单有很多通过吗?