Clean up documentation and infrastructure configuration files, and refine API resources and controllers for products and services.
This commit is contained in:
@@ -18,6 +18,7 @@ class ProductCategoryResource extends JsonResource
|
||||
'sort_order' => $this->sort_order,
|
||||
'type' => $this->type,
|
||||
'type_label' => $this->type_label,
|
||||
'page_type' => $this->resolvePageType($this->type),
|
||||
'created_at' => $this->created_at?->toISOString(),
|
||||
'children' => $this->whenLoaded('children', fn () =>
|
||||
self::collection($this->children)
|
||||
@@ -27,4 +28,15 @@ class ProductCategoryResource extends JsonResource
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
private function resolvePageType(?string $type): string
|
||||
{
|
||||
return match ($type) {
|
||||
'vps', 'cloud' => 'service_vps',
|
||||
'hosting', 'email', 'ssl' => 'service_hosting',
|
||||
'domain' => 'service_domain',
|
||||
'blog' => 'blog',
|
||||
default => 'service_vps',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,21 @@ class ProductCategoryResource extends JsonResource
|
||||
'sort_order' => $this->sort_order,
|
||||
'type' => $this->type,
|
||||
'type_label' => $this->type_label,
|
||||
'page_type' => $this->resolvePageType($this->type),
|
||||
'children' => $this->when($this->children, function () {
|
||||
return self::collection($this->children);
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
private function resolvePageType(?string $type): string
|
||||
{
|
||||
return match ($type) {
|
||||
'vps', 'cloud' => 'service_vps',
|
||||
'hosting', 'email', 'ssl' => 'service_hosting',
|
||||
'domain' => 'service_domain',
|
||||
'blog' => 'blog',
|
||||
default => 'service_vps',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class ServiceListResource extends JsonResource
|
||||
'description' => $this->description,
|
||||
'thumbnail' => $this->thumbnail ? asset($this->thumbnail) : null,
|
||||
'product_type' => $this->product_type,
|
||||
'page_type' => $this->resolvePageType($this->product_type),
|
||||
'specs' => [
|
||||
'cpu' => $this->cpu,
|
||||
'ram' => $this->ram,
|
||||
@@ -46,4 +47,15 @@ class ServiceListResource extends JsonResource
|
||||
})->unique('group')->values(),
|
||||
];
|
||||
}
|
||||
|
||||
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',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ class ServiceResource extends JsonResource
|
||||
'description' => $this->description,
|
||||
'thumbnail' => $this->thumbnail ? asset($this->thumbnail) : null,
|
||||
'product_type' => $this->product_type,
|
||||
'page_type' => $this->resolvePageType($this->product_type),
|
||||
'specs' => [
|
||||
'cpu' => (int) $this->cpu,
|
||||
'ram' => (int) $this->ram,
|
||||
@@ -77,4 +78,15 @@ class ServiceResource extends JsonResource
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
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