42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class InvoiceResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'client_id' => $this->client_id,
|
|
'group_id' => $this->group_id,
|
|
'source_quote_id' => $this->source_quote_id,
|
|
'invoice_number' => $this->invoice_number,
|
|
'status' => $this->status,
|
|
'invoice_date' => $this->invoice_date,
|
|
'due_date' => $this->due_date,
|
|
'currency' => $this->currency,
|
|
'total_ht' => $this->total_ht,
|
|
'total_tva' => $this->total_tva,
|
|
'total_ttc' => $this->total_ttc,
|
|
'e_invoicing_channel_id' => $this->e_invoicing_channel_id,
|
|
'e_invoice_status' => $this->e_invoice_status,
|
|
'created_at' => $this->created_at,
|
|
'updated_at' => $this->updated_at,
|
|
'client' => $this->whenLoaded('client'),
|
|
'group' => $this->whenLoaded('group'),
|
|
'sourceQuote' => $this->whenLoaded('sourceQuote'),
|
|
'lines' => InvoiceLineResource::collection($this->whenLoaded('lines')),
|
|
'history' => DocumentStatusHistoryResource::collection($this->whenLoaded('history')),
|
|
];
|
|
}
|
|
}
|