feat: refactor product detail retrieval to simplify variant handling and enhance response structure

This commit is contained in:
2026-07-01 01:05:21 +00:00
parent 429fa36b05
commit 1aa831f921
5 changed files with 98 additions and 90 deletions

View File

@@ -10,7 +10,6 @@ use App\Domains\Catalog\Services\ProductService;
use App\Domains\Tenant\Models\Tenant;
use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -30,12 +29,10 @@ class ProductController extends Controller
return ProductResource::make($product)->response()->setStatusCode(201);
}
public function show(Request $request, Tenant $tenant, Product $producto, ProductService $productService): ProductResource
public function show(Tenant $tenant, Product $producto, ProductService $productService): ProductResource
{
$producto = $this->resolveScopedProduct($tenant, $producto);
$variantId = $request->query('variant_id');
$variantId = is_numeric($variantId) ? (int) $variantId : null;
$producto = $productService->getProductDetail($tenant, $producto, $variantId);
$producto = $productService->getProductDetail($tenant, $producto);
return ProductResource::make($producto);
}