public function invoiceLines()
{
return $this->morphMany(InvoiceLine::class, 'invoiceable')
->orWhereHasMorph('invoiceable', [Product::class], function ($query) {
$query->whereHas('order', function ($query) {
$query->where('id', $this->id);
});
})
->orWhereHasMorph('invoiceable', [Attachment::class], function ($query) {
$query->whereHas('product.order', function ($query) {
$query->where('id', $this->id);
});
});
}
public function invoiceLines()
{
return $this->morphMany(InvoiceLine::class, 'invoiceable')
->orWhereHasMorph('invoiceable', [Product::class], function ($query) {
$query->whereHas('order', function ($query) {
$query->where('id', $this->id);
});
})
->orWhereHasMorph('invoiceable', [Attachment::class], function ($query) {
$query->whereHas('product.order', function ($query) {
$query->where('id', $this->id);
});
});
}