36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class PaymentResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'payment_number' => $this->payment_number,
|
|
'invoice' => [
|
|
'id' => $this->invoice->id,
|
|
'number' => $this->invoice->invoice_number,
|
|
],
|
|
'patient' => [
|
|
'id' => $this->invoice->patient->id,
|
|
'name' => $this->invoice->patient->fullName(),
|
|
],
|
|
'payment_date' => $this->payment_date->format('Y-m-d'),
|
|
'amount' => $this->amount,
|
|
'payment_method' => $this->payment_method,
|
|
'reference_number' => $this->reference_number,
|
|
'notes' => $this->notes,
|
|
'received_by' => [
|
|
'id' => $this->receivedBy->id,
|
|
'name' => $this->receivedBy->name,
|
|
],
|
|
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
|
|
];
|
|
}
|
|
}
|