34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class InvoiceResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'invoice_number' => $this->invoice_number,
|
|
'patient' => [
|
|
'id' => $this->patient->id,
|
|
'name' => $this->patient->fullName(),
|
|
],
|
|
'invoice_date' => $this->invoice_date->format('Y-m-d'),
|
|
'due_date' => $this->due_date->format('Y-m-d'),
|
|
'subtotal' => $this->subtotal,
|
|
'tax_amount' => $this->tax_amount,
|
|
'discount_amount' => $this->discount_amount,
|
|
'total_amount' => $this->total_amount,
|
|
'paid_amount' => $this->paid_amount,
|
|
'balance' => $this->balance,
|
|
'status' => $this->status,
|
|
'currency' => new CurrencyResource($this->currency),
|
|
'notes' => $this->notes,
|
|
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
|
];
|
|
}
|
|
}
|