26 lines
871 B
PHP
26 lines
871 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api\Service\Order;
|
|
|
|
use App\Enums\Invoice\InvoiceStatus;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class InvoiceSummaryResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'invoice_number' => $this->invoice_number,
|
|
'service_name' => $this->order?->orderItems->first()?->product?->name ?? ('Đơn hàng ' . $this->order?->order_num),
|
|
'total' => (float) $this->total,
|
|
'status' => $this->status,
|
|
'status_text' => InvoiceStatus::tryFrom((int) $this->status)?->label() ?? '-',
|
|
'created_at' => $this->created_at?->toISOString(),
|
|
'order_id' => $this->order?->id,
|
|
'order_num' => $this->order?->order_num,
|
|
];
|
|
}
|
|
}
|