feat: Add product specifications, order details, and VM information to the service client detail resource and eager load related data.
This commit is contained in:
@@ -18,17 +18,43 @@ class ServiceClientDetailResource extends JsonResource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$orderItem = $this->orderItem;
|
||||||
|
$order = $orderItem?->order;
|
||||||
|
$vm = $order?->vmWare?->first();
|
||||||
|
$product = $orderItem?->product;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'uuid' => $this->uuid,
|
'uuid' => $this->uuid,
|
||||||
'server_name' => $this->server_name,
|
'server_name' => $this->server_name,
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'auto_renew' => $this->auto_renew,
|
'auto_renew' => $this->auto_renew,
|
||||||
'started_at' => $this->started_at?->toISOString(),
|
'started_at' => $this->started_at?->toISOString(),
|
||||||
'expires_at' => $this->expires_at?->toISOString(),
|
'expires_at' => $this->expires_at?->toISOString(),
|
||||||
'os' => [
|
'os' => [
|
||||||
'version' => $this->orderItem?->os?->version,
|
'version' => $orderItem?->os?->version,
|
||||||
'group' => $this->orderItem?->os?->os_group?->name,
|
'group' => $orderItem?->os?->osGroup?->name,
|
||||||
],
|
],
|
||||||
|
'specs' => $product ? [
|
||||||
|
'cpu' => (int) ($product->cpu ?? 0),
|
||||||
|
'ram' => (int) ($product->ram ?? 0),
|
||||||
|
'disk' => (int) ($product->disk ?? 0),
|
||||||
|
'bandwidth' => (int) ($product->bandwidth ?? 0),
|
||||||
|
] : null,
|
||||||
|
'order' => $order ? [
|
||||||
|
'total' => (float) $order->total,
|
||||||
|
'months' => (int) $orderItem->months,
|
||||||
|
'billing_label' => $orderItem->billing_label,
|
||||||
|
] : null,
|
||||||
|
'vm' => $vm ? [
|
||||||
|
'id' => $vm->id,
|
||||||
|
'vmware_id' => $vm->vmware_id,
|
||||||
|
'ip_address' => $vm->ipAddress?->ip,
|
||||||
|
'hostname' => $vm->hostname,
|
||||||
|
'username' => $vm->user,
|
||||||
|
'password' => $vm->getRawOriginal('password'),
|
||||||
|
'port' => $vm->port,
|
||||||
|
'status' => $vm->status,
|
||||||
|
] : null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,11 @@ class ServiceClientRepository extends BaseApiRepository implements ServiceClient
|
|||||||
public function getDetailService(string $uuid)
|
public function getDetailService(string $uuid)
|
||||||
{
|
{
|
||||||
return $this->model
|
return $this->model
|
||||||
->with(['orderItem.os.osGroup.host.datacenter.vCenter'])
|
->with([
|
||||||
|
'orderItem.os.osGroup',
|
||||||
|
'orderItem.product',
|
||||||
|
'orderItem.order.vmWare.ipAddress',
|
||||||
|
])
|
||||||
->where('uuid', $uuid)
|
->where('uuid', $uuid)
|
||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user