【发布时间】:2014-09-18 13:24:45
【问题描述】:
我有一个这样建模的数据库:
User
+ id
+ email
+ password
Profile
+ id
+ owner_id (FK user.id)
+ type_id (FK types.id)
+ address_id (FK addresses.id)
+ org_name
+ phone
+ email
+ url
etc
Postings
+ id
+ profile_id (FK profiles.id)
+ title
+ description
Addresses
+ id
+ street
+ city
+ province_id (FK provinces.id)
+ country_id (FK countries.id)
etc
Countries
+ id
+ name
Provinces
+ id
+ name
+ abbreviation
+ country_id
我正在尝试使用 Eloquent ORM 根据 type_id、city、country_id 和/或 Province_id 从中查询一组 Postings。这些字段位于从属对象 $posting->profile->address 等上。
我是否将不得不简化我的数据库 - 通过将地址数据合并到其中来平整配置文件?或者有没有办法在 Eloquent 中做到这一点,而无需重塑我的所有数据?
【问题讨论】:
-
相关问题虽然未解决:stackoverflow.com/questions/24975987/…
标签: laravel orm eloquent relationship