1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Add vendor & expense includes for purchase orders

This commit is contained in:
Benjamin Beganović 2022-08-23 14:15:09 +02:00
parent 8fa4883736
commit e4a9ae4526

View File

@ -14,6 +14,7 @@ namespace App\Transformers;
use App\Models\PurchaseOrder;
use App\Models\PurchaseOrderInvitation;
use App\Models\Vendor;
use App\Transformers\DocumentTransformer;
use App\Utils\Traits\MakesHash;
@ -27,7 +28,8 @@ class PurchaseOrderTransformer extends EntityTransformer
];
protected $availableIncludes = [
'expense'
'expense',
'vendor',
];
public function includeInvitations(PurchaseOrder $purchase_order)
@ -49,7 +51,22 @@ class PurchaseOrderTransformer extends EntityTransformer
{
$transformer = new ExpenseTransformer($this->serializer);
return $this->includeItem($purchase_order->expense, $transformer, Document::class);
if (!$purchase_order->expense) {
return null;
}
return $this->includeItem($purchase_order->expense, $transformer, Expense::class);
}
public function includeVendor(PurchaseOrder $purchase_order)
{
$transformer = new VendorTransformer($this->serializer);
if (!$purchase_order->vendor) {
return null;
}
return $this->includeItem($purchase_order->vendor, $transformer, Vendor::class);
}
public function transform(PurchaseOrder $purchase_order)