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

28 lines
1010 B
PHP
Raw Normal View History

2015-11-03 15:21:17 +01:00
<?php namespace App\Ninja\Transformers;
2015-11-08 22:12:50 +01:00
use App\Models\Account;
2015-11-03 15:21:17 +01:00
use App\Models\InvoiceItem;
use League\Fractal;
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)
{
return [
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-11-08 22:12:50 +01:00
'account_key' => $this->account->account_key,
2015-11-07 13:15:37 +01:00
'user_id' => (int) $item->user_id,
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
'product_key' => $item->product_key,
'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-04-08 13:25:06 +02:00
'tax_name2' => $item->tax_name2 ? $item->tax_name1 : '',
2016-03-31 11:29:01 +02:00
'tax_rate2' => (float) $item->tax_rate2,
2015-11-03 15:21:17 +01:00
];
}
}