Closed airliajsmith closed 3 years ago
Have you already defined these relationships?
Yes, but I'm not certain I did it correctly.
In Purchase Model:
public function shipments()
{
return $this->belongsToMany('App\Models\Purchasing\Shipment', 'purchase_shipment');
}
public function vendor()
{
return $this->belongsTo('App\Models\Vendor\Vendor');
}
In Vendor Model:
public function shipments()
{
return $this->hasManyThrough('App\Models\Purchasing\Shipment', 'App\Models\Purchasing\Purchase',
'shipments.id', 'purchases.vendor_id');
}
Shipment Model:
public function purchase(){
return $this->belongsToMany('App\Models\Purchasing\Purchase', 'purchase_shipment');
}
public function vendor(){
return $this->hasOneThrough('App\Models\Vendor\Vendor', 'App\Models\Purchasing\Purchase',
'purchases.vendor_id', 'purchases.id');
}
What relationship are looking to define?
Purchase Orders can have multiple shipments. Shipments can send multiple Purchase Orders at one time.
Both are related to Vendors. Right now, I have the vendor setup through the Purchase Orders.
How do I use your package in this situation?