1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 14:12:44 +01:00
invoiceninja/app/Ninja/Transformers/InvoiceItemTransformer.php
2017-12-21 19:56:07 +02:00

30 lines
1.1 KiB
PHP

<?php
namespace App\Ninja\Transformers;
use App\Models\InvoiceItem;
class InvoiceItemTransformer extends EntityTransformer
{
public function transform(InvoiceItem $item)
{
return array_merge($this->getDefaults($item), [
'id' => (int) $item->public_id,
'product_key' => $item->product_key,
'updated_at' => $this->getTimestamp($item->updated_at),
'archived_at' => $this->getTimestamp($item->deleted_at),
'notes' => $item->notes,
'cost' => (float) $item->cost,
'qty' => (float) $item->qty,
'tax_name1' => $item->tax_name1 ? $item->tax_name1 : '',
'tax_rate1' => (float) $item->tax_rate1,
'tax_name2' => $item->tax_name2 ? $item->tax_name2 : '',
'tax_rate2' => (float) $item->tax_rate2,
'invoice_item_type_id' => (int) $item->invoice_item_type_id,
'custom_value1' => $item->custom_value1,
'custom_value2' => $item->custom_value2,
'discount' => (float) $item->discount,
]);
}
}