feat: Add service date handling and enhance service details in response
This commit is contained in:
@@ -12,8 +12,17 @@ class ServiceClientDetailResource extends JsonResource
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function resolveSpecs($product): ?array
|
||||
private function resolveSpecs($vm, $product): ?array
|
||||
{
|
||||
if ($vm && ($vm->cpu !== null || $vm->ram_mb !== null || $vm->disk_gb !== null)) {
|
||||
return [
|
||||
'cpu' => (int) ($vm->cpu ?? 0),
|
||||
'ram' => (int) ($vm->ram_mb ?? 0),
|
||||
'disk' => (int) ($vm->disk_gb ?? 0),
|
||||
'bandwidth' => (int) ($product->bandwidth ?? 0),
|
||||
];
|
||||
}
|
||||
|
||||
$addons = $this->addons ?? collect();
|
||||
if ($addons->isNotEmpty()) {
|
||||
return [
|
||||
@@ -51,10 +60,10 @@ class ServiceClientDetailResource extends JsonResource
|
||||
'started_at' => $this->started_at?->toISOString(),
|
||||
'expires_at' => $this->expires_at?->toISOString(),
|
||||
'os' => [
|
||||
'version' => $orderItem?->os?->version,
|
||||
'group' => $orderItem?->os?->osGroup?->name,
|
||||
'version' => $orderItem?->os?->version ?? $vm?->os?->version,
|
||||
'group' => $orderItem?->os?->osGroup?->name ?? $vm?->os?->osGroup?->name,
|
||||
],
|
||||
'specs' => $this->resolveSpecs($product),
|
||||
'specs' => $this->resolveSpecs($vm, $product),
|
||||
'order' => $order ? [
|
||||
'total' => (float) $order->total,
|
||||
'months' => (int) $orderItem->months,
|
||||
@@ -63,7 +72,7 @@ class ServiceClientDetailResource extends JsonResource
|
||||
'vm' => $vm ? [
|
||||
'id' => $vm->id,
|
||||
'vmware_id' => $vm->vmware_id,
|
||||
'ip_address' => $vm->ipAddress?->ip,
|
||||
'ip_address' => $vm->ipAddress?->ip ?? $vm->ip,
|
||||
'hostname' => $vm->hostname,
|
||||
'username' => $vm->user,
|
||||
'password' => $vm->plain_password ?? null,
|
||||
|
||||
Reference in New Issue
Block a user