What would be the proper way to configure the (one to one) relationships in this setup? Not entirely sure what approach to take :/
class Order extends Model {
// This model has billing_address_id and shipping_address_id fields
...
public function billing_address() {
return $this->belongsTo(OrderAddress::class);
}
public function shipping_address() {
return $this->belongsTo(OrderAddress::class);
}
// These are usually the same, but can link to 2 different OrderAddress records
...
}
class OrderAddress extends Model {
...
// A OrderAddress can only be used by a single Order
public function order() {
return $this->hasOne(Order::class, 'i cant use multiple foreign keys');
}
Thanks!