32 lines
1.4 KiB
PHP
32 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Invoices;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class InvoiceResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => (int) ($this->resource['id'] ?? 0),
|
|
'parent_id' => (int) ($this->resource['parent_id'] ?? 0),
|
|
'invoice_number' => $this->resource['invoice_number'] ?? null,
|
|
'total_amount' => (float) ($this->resource['total_amount'] ?? 0),
|
|
'paid_amount' => (float) ($this->resource['paid_amount'] ?? 0),
|
|
'balance' => (float) ($this->resource['balance'] ?? 0),
|
|
'status' => $this->resource['status'] ?? null,
|
|
'school_year' => $this->resource['school_year'] ?? null,
|
|
'semester' => $this->resource['semester'] ?? null,
|
|
'issue_date' => $this->resource['issue_date'] ?? null,
|
|
'due_date' => $this->resource['due_date'] ?? null,
|
|
'created_at' => $this->resource['created_at'] ?? null,
|
|
'updated_at' => $this->resource['updated_at'] ?? null,
|
|
'refund_amount' => (float) ($this->resource['refund_amount'] ?? 0),
|
|
'last_paid_amount' => (float) ($this->resource['last_paid_amount'] ?? 0),
|
|
'last_payment_date' => $this->resource['last_payment_date'] ?? null,
|
|
];
|
|
}
|
|
}
|