If I have properties
table, and 2 other tables:
*property_characteristics
- property_id (i.e. 1)
- characteristic_id (i.e. 5 - join with default_characteristics)
- value (i.e. 3 - aka 3 rooms)
*default_characteristics
- id (i.e. 5)
- name (i.e. rooms)
In the Property.php model I have:
public function characteristics()
{
return $this->belongsToMany('Proactiv\DefaultCharacteristic', 'property_characteristics', 'property_id', 'characteristic_id');
}
How can I get the number of rooms (value from property_characteristics) for a property starting from:
$property = Properties::find(1);
I would need something like this in view:
$property->characteristics->rooms // should return 3 which is the value columns on property_characteristics table