1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00
invoiceninja/app/Ninja/Transformers/InvoiceItemTransformer.php

30 lines
1.1 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Ninja\Transformers;
2015-11-03 15:21:17 +01:00
use App\Models\InvoiceItem;
2015-11-08 22:12:50 +01:00
class InvoiceItemTransformer extends EntityTransformer
2015-11-03 15:21:17 +01:00
{
public function transform(InvoiceItem $item)
{
2016-05-03 22:02:29 +02:00
return array_merge($this->getDefaults($item), [
2015-11-15 11:43:32 +01:00
'id' => (int) $item->public_id,
2015-11-03 15:21:17 +01:00
'product_key' => $item->product_key,
2015-12-27 12:08:58 +01:00
'updated_at' => $this->getTimestamp($item->updated_at),
'archived_at' => $this->getTimestamp($item->deleted_at),
2015-11-07 13:15:37 +01:00
'notes' => $item->notes,
'cost' => (float) $item->cost,
'qty' => (float) $item->qty,
2016-04-08 13:25:06 +02:00
'tax_name1' => $item->tax_name1 ? $item->tax_name1 : '',
2016-03-31 11:29:01 +02:00
'tax_rate1' => (float) $item->tax_rate1,
2016-07-15 23:52:00 +02:00
'tax_name2' => $item->tax_name2 ? $item->tax_name2 : '',
2016-03-31 11:29:01 +02:00
'tax_rate2' => (float) $item->tax_rate2,
2017-03-26 11:55:47 +02:00
'invoice_item_type_id' => (int) $item->invoice_item_type_id,
2017-09-20 03:33:58 +02:00
'custom_value1' => $item->custom_value1,
'custom_value2' => $item->custom_value2,
2017-12-21 18:56:07 +01:00
'discount' => (float) $item->discount,
2016-05-03 22:02:29 +02:00
]);
2015-11-03 15:21:17 +01:00
}
2016-07-15 23:52:00 +02:00
}