|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Squareetlabs\VeriFactu\Http\Resources; |
|
6
|
|
|
|
|
7
|
|
|
use Illuminate\Http\Resources\Json\JsonResource; |
|
8
|
|
|
|
|
9
|
|
|
class InvoiceResource extends JsonResource |
|
10
|
|
|
{ |
|
11
|
|
|
public function toArray($request): array |
|
12
|
|
|
{ |
|
13
|
|
|
return [ |
|
14
|
|
|
'id' => $this->id, |
|
|
|
|
|
|
15
|
|
|
'uuid' => $this->uuid, |
|
|
|
|
|
|
16
|
|
|
'number' => $this->number, |
|
|
|
|
|
|
17
|
|
|
'date' => $this->date?->format('Y-m-d'), |
|
|
|
|
|
|
18
|
|
|
'customer_name' => $this->customer_name, |
|
|
|
|
|
|
19
|
|
|
'customer_tax_id' => $this->customer_tax_id, |
|
|
|
|
|
|
20
|
|
|
'customer_country' => $this->customer_country, |
|
|
|
|
|
|
21
|
|
|
'issuer_name' => $this->issuer_name, |
|
|
|
|
|
|
22
|
|
|
'issuer_tax_id' => $this->issuer_tax_id, |
|
|
|
|
|
|
23
|
|
|
'issuer_country' => $this->issuer_country, |
|
|
|
|
|
|
24
|
|
|
'amount' => $this->amount, |
|
|
|
|
|
|
25
|
|
|
'tax' => $this->tax, |
|
|
|
|
|
|
26
|
|
|
'total' => $this->total, |
|
|
|
|
|
|
27
|
|
|
'type' => $this->type, |
|
|
|
|
|
|
28
|
|
|
'external_reference' => $this->external_reference, |
|
|
|
|
|
|
29
|
|
|
'description' => $this->description, |
|
|
|
|
|
|
30
|
|
|
'status' => $this->status, |
|
|
|
|
|
|
31
|
|
|
'issued_at' => $this->issued_at?->toIso8601String(), |
|
|
|
|
|
|
32
|
|
|
'cancelled_at' => $this->cancelled_at?->toIso8601String(), |
|
|
|
|
|
|
33
|
|
|
'created_at' => $this->created_at?->toIso8601String(), |
|
|
|
|
|
|
34
|
|
|
'updated_at' => $this->updated_at?->toIso8601String(), |
|
|
|
|
|
|
35
|
|
|
'breakdowns' => BreakdownResource::collection($this->whenLoaded('breakdowns')), |
|
36
|
|
|
'recipients' => RecipientResource::collection($this->whenLoaded('recipients')), |
|
37
|
|
|
]; |
|
38
|
|
|
} |
|
39
|
|
|
} |