whenLoaded('pricings', function () { return $this->pricings->min('price'); }); return [ 'id' => $this->id, 'uuid' => $this->uuid, 'name' => $this->name, 'slug' => $this->slug, 'product_type' => $this->product_type, 'page_type' => $this->resolvePageType($this->product_type), 'product_categories_id' => $this->whenLoaded('category', fn() => $this->category?->id), 'category' => $this->whenLoaded('category', fn() => $this->category?->name), 'cpu' => $this->cpu, 'ram' => $this->ram, 'disk' => $this->disk, 'bandwidth' => $this->bandwidth, 'setup_fee' => $this->setup_fee, 'min_price' => $minPrice, 'is_active' => $this->is_active, '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', }; } }