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