Basit şekli şu şekilde:
properties (Property)
- İlanları tutacak
feature_categories (FeatureCategory)
- Özellik kategorilerini tutuacak
- Ör: Cephe, iç özellikler, dış özellikler, ulaşım vs
features (Feature)
- Özellik kategorilerine ait değerleri tutacak
- Ör: Cephe için kuzey, güney, doğu, batı
properties_has_features (pivot tablo)
- İlanın sahip olduğu özellikleri tutacak
- property_id, feature_id
option_categories (OptionCategory)
- Seçenekleri tutacak
- Ör: Oda sayısı, kat, ısıtma, eşyalı mı, kiracılı mı, aidat var mı vs
options (Option)
- Seçenek değelerini tutacak
- Ör: Oda sayısı için 1+0, 1+1, 2+1 vs
properties_has_options (pivot tablo)
- İlanın sahip olduğu seçenekleri tutacak
- property_id, option_id
Property → belongsToMany → Feature → belongsTo → FeatureCategory → hasMany → Feature
Property → belongsToMany → Option → belongsTo → OptionCategory → hasMany → Option
// app/Property.php
public function features()
{
return $this->belongsToMany(Feature::class, 'properties_has_features', 'property_id', 'feature_id');
}
public function options()
{
return $this->belongsToMany(Option::class, 'properties_has_options', 'property_id', 'option_id');
}