【发布时间】:2018-10-08 04:34:49
【问题描述】:
我有三张桌子
属性:
- property_id
- 标题
房产价格:
- property_price_id
- currency_id
- 价格
货币
- currency_id
- 标题
属性模型:
public function PropertyPrice(){
return $this->hasMany('App\PropertyPrice','property_id');
}
物业价格模型:
public function Currency(){
return $this->belongsTo('App\Currency','currency_id');
}
public function Property(){
return $this->belongsTo('App\Property','property_id');
}
货币模型
public function PropertyPrice(){
return $this->hasMany('App\PropertyPrice','currency_id');
}
现在我正在运行这个 Eloquent 命令来获取带有价格的属性,
Property::with('PropertyPrice')->orderBy('ordering','desc')->paginate(10);
但我很困惑如何获得货币名称?请注意,我在“有很多通过”下看到了官方文档中提供的示例,但它是一个不同的示例,我无法与之相关。
请帮忙,谢谢
【问题讨论】:
标签: laravel-5 eloquent relationship