2015-11-03 20:03:24 +01:00
|
|
|
<?php namespace App\Ninja\Transformers;
|
|
|
|
|
|
|
|
use App\Models\Invoice;
|
|
|
|
|
2015-11-08 22:12:50 +01:00
|
|
|
class QuoteTransformer extends EntityTransformer
|
2015-11-03 20:03:24 +01:00
|
|
|
{
|
|
|
|
protected $defaultIncludes = [
|
|
|
|
'invoice_items',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function includeInvoiceItems($invoice)
|
|
|
|
{
|
2015-11-27 13:55:28 +01:00
|
|
|
$transformer = new InvoiceItemTransformer($this->account, $this->serializer);
|
|
|
|
return $this->includeCollection($invoice->invoice_items, $transformer, 'invoice_items');
|
2015-11-03 20:03:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function transform(Invoice $invoice)
|
|
|
|
{
|
|
|
|
return [
|
2015-11-15 11:43:32 +01:00
|
|
|
'id' => (int) $invoice->public_id,
|
2015-11-03 20:03:24 +01:00
|
|
|
'quote_number' => $invoice->invoice_number,
|
|
|
|
'amount' => (float) $invoice->amount,
|
2015-12-17 09:19:56 +01:00
|
|
|
'quote_terms' => $invoice->terms,
|
2015-11-03 20:03:24 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|