Clean up documentation and infrastructure configuration files, and refine API resources and controllers for products and services.
This commit is contained in:
@@ -19,6 +19,7 @@ class ProductResource extends JsonResource
|
||||
'name' => $this->name,
|
||||
'slug' => $this->slug,
|
||||
'product_type' => $this->product_type,
|
||||
'page_type' => $this->resolvePageType($this->product_type),
|
||||
'category' => $this->whenLoaded('category', fn() => $this->category?->name),
|
||||
'cpu' => $this->cpu,
|
||||
'ram' => $this->ram,
|
||||
@@ -30,4 +31,15 @@ class ProductResource extends JsonResource
|
||||
'created_at' => $this->created_at,
|
||||
];
|
||||
}
|
||||
|
||||
private function resolvePageType(?string $productType): string
|
||||
{
|
||||
return match ($productType) {
|
||||
'vps', 'cloud' => 'service_vps',
|
||||
'hosting', 'email', 'ssl' => 'service_hosting',
|
||||
'domain' => 'service_domain',
|
||||
'blog' => 'blog',
|
||||
default => 'service_vps',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user