i have three tables
Property:
- property_id
- title
Property Prices:
- property_price_id
- currency_id
- price
currencies
- currency_id
- title
Property Model:
public function PropertyPrice(){
return $this->hasMany('App\PropertyPrice','property_id');
}
property Price Model:
public function Currency(){
return $this->belongsTo('App\Currency','currency_id');
}
public function Property(){
return $this->belongsTo('App\Property','property_id');
}
Currency Model
public function PropertyPrice(){
return $this->hasMany('App\PropertyPrice','currency_id');
}
Now i am running this Eloquent command for getting properties with prices,
Property::with('PropertyPrice')->orderBy('ordering','desc')->paginate(10);
but i am confused how to get the currency title? please note i have seen the example provided on official documentation under "Has Many Through" but its a different example , i am unable to relate to it.
please help, thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire