1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 21:52:35 +01:00
invoiceninja/app/Ninja/Transformers/InvoiceTransformer.php
2015-11-03 16:21:17 +02:00

27 lines
695 B
PHP

<?php namespace App\Ninja\Transformers;
use App\Models\Invoice;
use League\Fractal;
use League\Fractal\TransformerAbstract;
class InvoiceTransformer extends TransformerAbstract
{
protected $defaultIncludes = [
'invoice_items',
];
public function includeInvoiceItems($invoice)
{
return $this->collection($invoice->invoice_items, new InvoiceItemTransformer);
}
public function transform(Invoice $invoice)
{
return [
'id' => (int) $invoice->public_id,
'invoice_number' => $invoice->invoice_number,
'amount' => (float) $invoice->amount,
'balance' => (float) $invoice->balance,
];
}
}