So you want 1 product or multiple? I assume multiple
$products = Product::where('name', 'LIKE', "%{$search}%")
->orWhere('price', 'LIKE', "%{$price}%" )->get();
if ($products->isNotEmpty()) {
return $this->handleResponse(ProductResource::collection($product), 'Products Retrieved.' );
}
If you only expect 1 product
$product = Product::where('name', 'LIKE', "%{$search}%")
->orWhere('price', 'LIKE', "%{$price}%" )->first(); //get the first()
if ($product) {
return $this->handleResponse(new ProductResource($product), 'Product Retrieved.' );
}