34 lines
1.2 KiB
PHP
34 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Api\Service\Order;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ServiceSummaryResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'uuid' => $this->uuid,
|
|
'service_name' => $this->product?->name ?? $this->server_name,
|
|
'server_name' => $this->server_name,
|
|
'product_type' => $this->product?->product_type,
|
|
'billing_cycle' => $this->orderItem?->billing_cycle,
|
|
'status' => $this->status,
|
|
'status_text' => $this->status_label,
|
|
'auto_renew' => (bool) $this->auto_renew,
|
|
'started_at' => $this->started_at?->toISOString(),
|
|
'expires_at' => $this->expires_at?->toISOString(),
|
|
'invoice_id' => $this->invoice_id,
|
|
'invoice_number' => $this->invoice?->invoice_number,
|
|
'addons' => $this->whenLoaded('addons', fn () => $this->addons->map(fn ($a) => [
|
|
'type' => $a->addon_type,
|
|
'value' => $a->addon_value,
|
|
'price' => $a->price,
|
|
])->all()),
|
|
];
|
|
}
|
|
}
|