43 lines
1.6 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class AvoirResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'client_id' => $this->client_id,
'invoice_id' => $this->invoice_id,
'group_id' => $this->group_id,
'avoir_number' => $this->avoir_number,
'status' => $this->status,
'avoir_date' => $this->avoir_date,
'due_date' => $this->due_date,
'currency' => $this->currency,
'total_ht' => $this->total_ht,
'total_tva' => $this->total_tva,
'total_ttc' => $this->total_ttc,
'reason_type' => $this->reason_type,
'reason_description' => $this->reason_description,
'e_invoice_status' => $this->e_invoice_status,
'refund_status' => $this->refund_status,
'refund_date' => $this->refund_date,
'refund_method' => $this->refund_method,
'compensation_invoice_id' => $this->compensation_invoice_id,
'compensation_amount' => $this->compensation_amount,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'client' => $this->whenLoaded('client'),
'invoice' => $this->whenLoaded('invoice'),
'group' => $this->whenLoaded('group'),
'lines' => AvoirLineResource::collection($this->whenLoaded('lines')),
'history' => DocumentStatusHistoryResource::collection($this->whenLoaded('history')),
];
}
}