Files
2026-06-15 09:11:57 +07:00

41 lines
1.5 KiB
PHP

<?php
namespace App\Http\Resources\Api\Service\Order;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class OrderItemResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'billing_cycle' => $this->billing_cycle,
'months' => $this->months,
'server_name' => $this->server_name,
'os_id' => $this->os_id,
'price' => (float) $this->price,
'service' => $this->whenLoaded('service', fn () => [
'id' => $this->service->id,
'status' => $this->service->status,
'status_text' => $this->service->status_label,
'retry_requested_at' => $this->service->retry_requested_at?->toISOString(),
'can_retry_provisioning' => $this->service->status === 'pending' && ! $this->service->retry_requested_at,
]),
'product' => $this->whenLoaded('product', fn () => [
'id' => $this->product->id,
'uuid' => $this->product->uuid,
'name' => $this->product->name,
'product_type' => $this->product->product_type,
'specs' => [
'cpu' => $this->product->cpu,
'ram' => $this->product->ram,
'disk' => $this->product->disk,
'bandwidth' => $this->product->bandwidth,
],
]),
];
}
}