Level 55
@m24mohammadi for my mind, pivot with more than 2 foreign keys becomes separated model. Something like AdvertiseFieldValue
this way Advertise, Value and Field will hasMany AdvertiseFieldValue, and AdvertiseFieldValue will belongsTo all 3 models
this way you'll be able to eager load all relations, like
Advertise::with('advertiseFieldValues.field', 'fadvertiseFieldValues.value))->first();
or
Field::with('advertiseFieldValues.advertise', 'advertiseFieldValues.value))->first();
1 like